Skip to content

Commit 701825d

Browse files
dschogitster
authored andcommitted
add -e: do not show difference in a submodule that is merely dirty
When the HEAD of the submodule matches what is recorded in the index of the superproject, and it has local changes or untracked files, the patch offered by "git add -e" for editing shows a diff like this: diff --git a/submodule b/submodule <header> -deadbeef... +deadbeef...-dirty Because applying such a patch has no effect to the index, this is a useless noise. Generate the patch with IGNORE_DIRTY_SUBMODULES flag to prevent such a change from getting reported. This patch also loses the "-dirty" suffix from the output when the HEAD of the submodule is different from what is in the index of the superproject. As such dirtiness expressed by the suffix does not affect the result of the patch application at all, there is no information lost if we remove it. The user could still run "git status" before "git add -e" if s/he cares about the dirtiness. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f174a25 commit 701825d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

builtin/add.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
279279

280280
argc = setup_revisions(argc, argv, &rev, NULL);
281281
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
282+
DIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);
282283
out = open(file, O_CREAT | O_WRONLY, 0644);
283284
if (out < 0)
284285
die (_("Could not open '%s' for writing."), file);

0 commit comments

Comments
 (0)