File tree Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,18 @@ selected and output. Here fewest commits different is defined as
198
198
the number of commits which would be shown by `git log tag..input`
199
199
will be the smallest number of commits possible.
200
200
201
+ BACKGROUND REFRESH
202
+ ------------------
203
+
204
+ By default, `git describe --dirty` will automatically refresh the index,
205
+ similar to the background refresh functionality of
206
+ linkgit:git-status[1]. Writing out the updated index is an optimization
207
+ that isn't strictly necessary. When `describe` is run in the background,
208
+ the lock held during the write may conflict with other simultaneous
209
+ processes, causing them to fail. Scripts running `describe` in the
210
+ background should consider using `git --no-optional-locks status` (see
211
+ linkgit:git[1] for details).
212
+
201
213
BUGS
202
214
----
203
215
Original file line number Diff line number Diff line change @@ -189,7 +189,8 @@ If you just want to run git as if it was started in `<path>` then use
189
189
190
190
--no-optional-locks::
191
191
Do not perform optional operations that require locks. This is
192
- equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`.
192
+ equivalent to setting the `GIT_OPTIONAL_LOCKS` to `0`. This
193
+ functionality is implemented for `git status` and `git describe`.
193
194
194
195
--no-advice::
195
196
Disable all advice hints from being printed.
Original file line number Diff line number Diff line change @@ -704,18 +704,20 @@ int cmd_describe(int argc,
704
704
} else if (dirty ) {
705
705
struct lock_file index_lock = LOCK_INIT ;
706
706
struct rev_info revs ;
707
- int fd ;
708
707
709
708
setup_work_tree ();
710
709
prepare_repo_settings (the_repository );
711
710
the_repository -> settings .command_requires_full_index = 0 ;
712
711
repo_read_index (the_repository );
713
712
refresh_index (the_repository -> index , REFRESH_QUIET |REFRESH_UNMERGED ,
714
713
NULL , NULL , NULL );
715
- fd = repo_hold_locked_index (the_repository ,
716
- & index_lock , 0 );
717
- if (0 <= fd )
718
- repo_update_index_if_able (the_repository , & index_lock );
714
+ if (use_optional_locks ()) {
715
+ int fd = repo_hold_locked_index (the_repository ,
716
+ & index_lock , 0 );
717
+ if (0 <= fd )
718
+ repo_update_index_if_able (the_repository ,
719
+ & index_lock );
720
+ }
719
721
720
722
repo_init_revisions (the_repository , & revs , prefix );
721
723
Original file line number Diff line number Diff line change @@ -749,4 +749,12 @@ test_expect_success 'do not be fooled by invalid describe format ' '
749
749
test_must_fail git cat-file -t "refs/tags/super-invalid/./../...../ ~^:/?*[////\\\\\\&}/busted.lock-42-g"$(cat out)
750
750
'
751
751
752
+ test_expect_success ' --no-optional-locks prevents index update' '
753
+ test_set_magic_mtime .git/index &&
754
+ git --no-optional-locks describe --dirty &&
755
+ test_is_magic_mtime .git/index &&
756
+ git describe --dirty &&
757
+ ! test_is_magic_mtime .git/index
758
+ '
759
+
752
760
test_done
You can’t perform that action at this time.
0 commit comments