git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] add -e: ignore dirty submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 7, 2012, 08:21 UTC
Message-ID
<7vk43z2gwc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.1202070124020.4897@bonsai2>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 8 quoted lines
> Offering to add changes represented by a diff like
>
> diff --git <blub>
> <header>
> -deadbeef...
> +deadbeef...-dirty
>
> does not make sense.

Now you are being much clearer. If you had the above from the beginning, I wouldn't have had to ask.

So after all, this is a noise reduction patch, and I think that it is a good change.

Show 8 quoted lines
> Even a diff like
>
> diff --git <blah>
> <header>
> -deadbeef...
> -coffeebabe...-dirty
>
> would be refused by git-apply.

That would be refused, but if you replace '-coffeebabe' with '+coffeebabe', which is what you would get from "git diff" without ignore-dirty-submodule, I think it would be accepted by "git apply" just fine.

Have you tried it?
> I actually enjoyed writing this text so much, may I respectfully ask to
> include it verbatim in the commit message?
With mostly irrelevant mumblings and all?  Of course not.

I was asking what you meant to achieve with the patch, because you did not even include relevant bits of information.

But now I think I learned what you meant by this patch, so let me try to see if I understood it correctly by rephrasing it.

Like this?
-- >8 --
Subject: add -e: do not show difference in a submodule that is merely dirty
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: Tue, 7 Feb 2012 05:05:48 +0100 (CET)

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 <johannes.schindelin@gmx.de>
---
 builtin/add.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/builtin/add.c b/builtin/add.c
index 1c42900..b79336d 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -280,6 +280,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
 
 	argc = setup_revisions(argc, argv, &rev, NULL);
 	rev.diffopt.output_format = DIFF_FORMAT_PATCH;
+	DIFF_OPT_SET(&rev.diffopt, IGNORE_DIRTY_SUBMODULES);
 	out = open(file, O_CREAT | O_WRONLY, 0644);
 	if (out < 0)
 		die (_("Could not open '%s' for writing."), file);
Previous: Johannes SchindelinNext: Jens Lehmann
Message 4 of 5 in “add -e: ignore dirty submodules”
  1. add -e: ignore dirty submodulesJohannes Schindelin, Feb 7, 2012
  2. Junio C HamanoFeb 7, 2012
  3. Johannes SchindelinFeb 7, 2012
  4. Junio C HamanoFeb 7, 2012
  5. Jens LehmannFeb 7, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.