Skip to content

Commit 547e8b9

Browse files
jrngitster
authored andcommitted
fast-import: introduce "feature notes" command
Here is a 'feature' command for streams to use to require support for the notemodify (N) command. When the 'feature' facility was introduced (v1.7.0-rc0~95^2~4, 2009-12-04), the notes import feature was old news (v1.6.6-rc0~21^2~8, 2009-10-09) and it was not obvious it deserved to be a named feature. But now that is clear, since all major non-git fast-import backends lack support for it. Details: on git version with this patch applied, any "feature notes" command in the features/options section at the beginning of a stream will be treated as a no-op. On fast-import implementations without the feature (and older git versions), the command instead errors out with a message like This version of fast-import does not support feature notes. So by declaring use of notes at the beginning of a stream, frontends can avoid wasting time and other resources when the backend does not support notes. (This would be especially important for backends that do not support rewinding history after a botched import.) Improved-by: Thomas Rast <[email protected]> Improved-by: Sverre Rabbelier <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 68595cd commit 547e8b9

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

Documentation/git-fast-import.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,12 @@ import-marks::
898898
second, an --import-marks= command-line option overrides
899899
any "feature import-marks" command in the stream.
900900

901+
notes::
902+
Require that the backend support the 'notemodify' (N)
903+
subcommand to the 'commit' command.
904+
Versions of fast-import not supporting notes will exit
905+
with a message indicating so.
906+
901907
`option`
902908
~~~~~~~~
903909
Processes the specified option so that git fast-import behaves in a

fast-import.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,6 +2821,8 @@ static int parse_one_feature(const char *feature, int from_stream)
28212821
relative_marks_paths = 0;
28222822
} else if (!prefixcmp(feature, "force")) {
28232823
force_update = 1;
2824+
} else if (!strcmp(feature, "notes")) {
2825+
; /* do nothing; we have the feature */
28242826
} else {
28252827
return 0;
28262828
}

t/t9301-fast-import-notes.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ test_expect_success 'add notes with simple M command' '
120120

121121
test_tick
122122
cat >input <<INPUT_END
123+
feature notes
123124
commit refs/notes/test
124125
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
125126
data <<COMMIT

0 commit comments

Comments
 (0)