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

Re: Re: Re: Remove need to untrack before tracking new branch

From
MSMartin Schlemmer <azarah@nosferatu.za.org>
Date
Apr 14, 2005, 06:55 UTC
Message-ID
<1113461754.23299.68.camel@nosferatu.lan>
In-Reply-To
<20050413221936.GI25711@pasky.ji.cz>
On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:
Show 46 quoted lines
> Dear diary, on Wed, Apr 13, 2005 at 02:15:37PM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > On Wed, 2005-04-13 at 11:26 +0200, Petr Baudis wrote:
> >> > Dear diary, on Wed, Apr 13, 2005 at 10:41:12AM CEST, I got a letter
> > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > > On Wed, 2005-04-13 at 09:54 +0200, Petr Baudis wrote:
> > > > PS: not having looked deeper yet, why does fsck-cache always find
> > > > unreferenced blobs/commits (no matter what tree is tracked, they stay
> > > > the same) ?  And trying to remove them leads to more, which leads to an
> > > > empty .git/opjects/ =)  Also, leading to this, will adding an option to
> > > > remove disconnected commits/blobs from local commits (that was
> > > > disconnected with a pull) be a viable option to add?
> > > 
> > > fsck-cache is concerned only by the objects database, so all the HEADs
> > > are unreferenced commits too. This is a right thing, the HEAD tracking
> > > should stay purely in the scripts - if we want to make fsck-cache
> > > smarter about that, we should implement git fsck or something.
> > > 
> > > Killing unreferenced blobs should be safe, I think.
> > > 
> > > > First, about the 'git diff' thing I asked yesterday .. what I meant, was
> > > > should it actually output this:
> > > > 
> > > > ----
> > > > COPYING:  fe2a4177a760fd110e78788734f167bd633be8de 33
> > > > Makefile:  929aa49a3dbe683ad52094099797bc636a7949a6 33
> > > > README:  46c6a9ea48ddd1dda45ca585f49975a6869ffe51 33
> > > > ...
> > > > ----
> > > > 
> > > > Shouldn't it just show actual changes?
> > > 
> > > This is an actual change. It's just that it's a change to metadata
> > > (somewhat esotherically described by the "33"), not the file contents.
> > > 
> > > BTW, git diff does actually something completely different from git diff
> > > with any arguments. It diffs to the directory cache, not to any tree! It
> > > just wraps show-diff, which has also a different output format (not
> > > outputting "git diffs"). The worst thing is that it requires a different
> > > -p option to apply. Someone should purge this wart, I think.
> > > 
> > 
> > Check applied patch (also in the new output).
> 
> Please send patches inline and properly signed off.
> 
The new evo have a bad habit of screwing the tabs, but sure.
Show 15 quoted lines
> > > > Also on the same note .. should 'git ci' without listed files to be
> > > > committed, really add a reference to all files as it currently do in the
> > > > commit/blob/whatever info, instead of just the changed/added files (see
> > > > the git-seperate-dir.patch you have not yet commented on for reference)?
> > > 
> > > ...
> > > 
> > 
> > Patch will also resolve this.
> 
> Your patch is bad - it removes the pure metadata changes, but you
> definitively do not want to do that! If you are annoyed by meaningless
> time changes etc, do update-cache --refresh. Ignoring mode changes is a
> pure disaster.
> 

Ahh - and there was light. I do not have a problem with the mode changes - its just _all_ files was shown after tracked branch was changed. How about below patch?

Show 11 quoted lines
> > > > I know its in its infancy, but I am not sure on what scm you are basing
> > > > it, so not sure how things should behave.
> > > 
> > > I'm trying to base it on common sense and principle of least surprise.
> > > :-)
> > > 
> > 
> > Ok, I'll just bug you then if I am not sure on how you want something ;p
> 
> Or do it somehow and I'll bug you back if I don't like it. ;-)
> 
Ditto
----

Normalize show-diff output and make sure we only show real changes after changing the tracked branch.

Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>

gittrack.sh: a9d7c3d117390787e562a0450deb14c7cbf4b565 33 --- a9d7c3d117390787e562a0450deb14c7cbf4b565/gittrack.sh +++ uncommitted/gittrack.sh

@@ -49,6 +49,7 @@

        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       update-cache --refresh

 else
        [ "$tracking" ] || \
@@ -59,6 +60,7 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               update-cache --refresh

                head=$(cat .git/HEAD)
                branchhead=$(cat .git/HEAD.$tracking)
show-diff.c:  136ec315b82d10d33ff9b4517f1b8ab91e3dcabc 33
--- 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc/show-diff.c
+++ uncommitted/show-diff.c
@@ -5,13 +5,18 @@
  */
 #include "cache.h"

-static void show_differences(char *name,
+static void show_differences(struct cache_entry *ce,
        void *old_contents, unsigned long long old_size)
 {
        static char cmd[1000];
+       static char sha1[41];
+       int n;
        FILE *f;

-       snprintf(cmd, sizeof(cmd), "diff -L %s -u -N  - %s", name, name);
+       for (n = 0; n < 20; n++)
+               snprintf(&(sha1[n*2]), 3, "%02x", ce->sha1[n]);
+       snprintf(cmd, sizeof(cmd), "diff -L %s/%s -L uncommitted/%s -u -N  - %s",
+               sha1, ce->name, ce->name, ce->name);
        f = popen(cmd, "w");
        if (old_size)
                fwrite(old_contents, old_size, 1, f);
@@ -98,7 +103,7 @@

                fflush(stdout);
                new = read_sha1_file(ce->sha1, type, &size);
-               show_differences(ce->name, new, size);
+               show_differences(ce, new, size);
                free(new);
        }
        return 0;
-- 
Martin Schlemmer



gittrack.sh:  a9d7c3d117390787e562a0450deb14c7cbf4b565 33
--- a9d7c3d117390787e562a0450deb14c7cbf4b565/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -49,6 +49,7 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	update-cache --refresh
 
 else
 	[ "$tracking" ] || \
@@ -59,6 +60,7 @@
 	if [ -s ".git/HEAD.local" ]; then
 		gitdiff.sh "$tracking" local | gitapply.sh
 		read-tree $(tree-id local)
+		update-cache --refresh
 
 		head=$(cat .git/HEAD)
 		branchhead=$(cat .git/HEAD.$tracking)
show-diff.c:  136ec315b82d10d33ff9b4517f1b8ab91e3dcabc 33
--- 136ec315b82d10d33ff9b4517f1b8ab91e3dcabc/show-diff.c
+++ uncommitted/show-diff.c
@@ -5,13 +5,18 @@
  */
 #include "cache.h"
 
-static void show_differences(char *name,
+static void show_differences(struct cache_entry *ce,
 	void *old_contents, unsigned long long old_size)
 {
 	static char cmd[1000];
+	static char sha1[41];
+	int n;
 	FILE *f;
 
-	snprintf(cmd, sizeof(cmd), "diff -L %s -u -N  - %s", name, name);
+	for (n = 0; n < 20; n++)
+		snprintf(&(sha1[n*2]), 3, "%02x", ce->sha1[n]);
+	snprintf(cmd, sizeof(cmd), "diff -L %s/%s -L uncommitted/%s -u -N  - %s",
+		sha1, ce->name, ce->name, ce->name);
 	f = popen(cmd, "w");
 	if (old_size)
 		fwrite(old_contents, old_size, 1, f);
@@ -98,7 +103,7 @@
 
 		fflush(stdout);
 		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
+		show_differences(ce, new, size);
 		free(new);
 	}
 	return 0;
Previous: Petr BaudisNext: Martin Schlemmer
Message 2 of 16 in “Re: Re: Re: Remove need to untrack before tracking new branch”
  1. Petr BaudisApr 13, 2005
  2. Martin SchlemmerApr 14, 2005
  3. Martin SchlemmerApr 14, 2005
  4. Martin SchlemmerApr 14, 2005
  5. Petr BaudisApr 14, 2005
  6. Martin SchlemmerApr 14, 2005
  7. Martin SchlemmerApr 14, 2005
  8. Alex RiesenApr 14, 2005
  9. Martin SchlemmerApr 15, 2005
  10. Paul JacksonApr 15, 2005
  11. Alex RiesenApr 15, 2005
  12. Petr BaudisApr 14, 2005
  13. Martin SchlemmerApr 14, 2005
  14. Petr BaudisApr 14, 2005
  15. Martin SchlemmerApr 14, 2005
  16. Martin SchlemmerApr 14, 2005

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.