Skip to content

feat(git-utimes): add ability to update directory timestamp#1247

Open
Xenira wants to merge 2 commits intotj:mainfrom
Xenira:feat/utimes-directories
Open

feat(git-utimes): add ability to update directory timestamp#1247
Xenira wants to merge 2 commits intotj:mainfrom
Xenira:feat/utimes-directories

Conversation

@Xenira
Copy link
Copy Markdown

@Xenira Xenira commented Apr 22, 2026

New flag --touch-dirs or -d allows to update directory timestamp when using git utimes command.

Refs: #1246

I haven't done much with awk till now. Only tested under linux with git 2.53.0.

@Xenira Xenira force-pushed the feat/utimes-directories branch from 2d0d280 to 1d33f8b Compare April 22, 2026 14:28
New flag `--touch-dirs` or `-d` allows to update directory timestamp when using `git utimes` command.

Refs: tj#1249
@Xenira Xenira force-pushed the feat/utimes-directories branch from 1d33f8b to 80d9e2e Compare April 22, 2026 14:30
Comment thread bin/git-utimes Outdated
;;
esac

shift
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shift modifies $@ but has no effect on the for loop's iteration (it already has its own copy).

Comment thread bin/git-utimes Outdated
op=le
;;
--touch-dirs | -d)
log_opts+=(--dirstat=files,0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--dirstat=files will override --diff-filter=d, so a directory will be touched with a timestamp from a deletion-only commit. Is this expected?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it we might want to include deletes when touching directories.
That would mirror the unix behaviour where the directory timestamp is updated on file deletes as well.

Comment thread bin/git-utimes Outdated
op=eq

for arg in "$@"; do
case "$arg" in
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation

Comment thread man/git-utimes.1 Outdated
.TH "GIT\-UTIMES" "1" "May 2022" "" "Git Extras"
.\" generated with Ronn-NG/v0.10.1
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
.TH "GIT\-UTIMES" "1" "January 1980" "" "Git Extras"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we are back to 1980

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didnt notice that. For some reason ronn can't get a valid date on my system. Fixed.

Comment thread bin/git-utimes
@@ -91,13 +105,17 @@ FILENAME==tmpfile {
}
# skip blank lines
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update this comment

Comment thread bin/git-utimes
# dirstat line
if ($1 ~ /^.+% .+\/$/) {
# remove percentage before path
gsub(/^.+% /, "", $1)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When calling in a suddir, will a path be stripped twice? One in here, another in line 120

@krlmlr
Copy link
Copy Markdown

krlmlr commented May 6, 2026

Unrelated, but could be perhaps addressed as part of this, since we're touching it here?

With recent Git 2.52.0 and git-extras 7.4.0, I see:

✗ git utimes                                 
'git whatchanged' is nominated for removal.

hint: You can replace 'git whatchanged <opts>' with:
hint:   git log <opts> --raw --no-merges
hint: Or make an alias:
hint:   git config set --global alias.whatchanged 'log --raw --no-merges'

If you still use this command, here's what you can do:

- read https://git-scm.com/docs/BreakingChanges.html
- check if anyone has discussed this on the mailing
  list and if they came up with something that can
  help you: https://lore.kernel.org/git/?q=git%20whatchanged
- send an email to <git@vger.kernel.org> to let us
  know that you still use this command and were unable
  to determine a suitable replacement

fatal: refusing to run without --i-still-use-this

Can you confirm?

@Xenira
Copy link
Copy Markdown
Author

Xenira commented May 6, 2026

This is already resolved on master. See #1245

@spacewander
Copy link
Copy Markdown
Collaborator

Let me kick off a new release over the weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants