git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Re: Re: Remove need to untrack before tracking new branch
       [not found]                 ` <1113394537.23299.51.camel@nosferatu.lan>
@ 2005-04-13 22:19                   ` Petr Baudis
  2005-04-14  6:55                     ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Petr Baudis @ 2005-04-13 22:19 UTC (permalink / raw)
  To: Martin Schlemmer; +Cc: git

I didn't weed out the replies since this was not cc'd to the mailing
list and I believe it could contain some useful information for google
or whatever to pick. :-)

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:
> > BTW, why aren't we cc'ing the list?
> > 
> 
> Hmm, no reason really.  If you want to, will do next time.
> 
> > 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.

> > > 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.

I'm sorry - the ellipsis was there so that I'll write up a reply for
that later but I forgot.

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.

> > > Secondly, how about style/error issues?  Basically on the style front,
> > > currently some scripts use bash - how about pure bash for all:
> > > 
> > > ----
> > > [[ -n ${tracking} ]] && \
> > > ----
> > > 
> > > rather than:
> > > 
> > > ----
> > > [ "$tracking" ] && \
> > > ----
> > > 
> > > as you do not need the quotes, and for checking files, etc, it just do
> > > better handling than single quotes.  I am prepared to do patches if you
> > > like.
> > 
> > Well. I'm just not used to it and not quite sure about how it behaves
> > etc. So far I tried to make it as sh-like as possible, using bash
> > features only when absolutely necessary. I'm not saying this is the best
> > approach, but I wouldn't change it *now* (especially since it would slow
> > me down which I really don't want now) if someone doesn't give me some
> > really compelling arguments.
> > 
> 
> No problem.
> 
..snip..
> > > 2) Did not add the gitapply.sh that was new in your tree
> > 
> > This very bug should be fixed by introduction of gitapply.sh. ;-)
> > 
> > Actually I forgot to implement this. Fixed now.
> > 
> > > I guess I might have done things wrong (wrong way around)?  But the
> > > actual question is this .. when I tried to switch, it failed on the
> > > gitapply.sh hunk, but went on anyway ... how about doing a patch
> > > --dry-run first, and showing the user what would happen if that fails,
> > > asking for confirmation?
> > 
> > Just s/merge -b/diff/ on the command line and it will show precisely
> > what it is going to apply.  When we get the automatic base detection
> > something to just print the base could be indeed useful.
> > 
> > If that fails, all what will happen is that the user gets rejects. No
> > big deal. He can anytime just back out by
> > 
> > 	git diff | patch -p0 -R
> > 
> > So, what did it "went on" with? The merge (nor the tracked pull) never
> > commits anything. That's up to you, after you resolve the conflicts and
> > make sure everything is right.
> > 
> 
> Ah, right.
> 
> > > 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. ;-)

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-13 22:19                   ` Re: Re: Remove need to untrack before tracking new branch Petr Baudis
@ 2005-04-14  6:55                     ` Martin Schlemmer
  2005-04-14  8:28                       ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14  6:55 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


[-- Attachment #1.1: Type: text/plain, Size: 5659 bytes --]

On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:
> 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.

> > > > 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?

> > > > 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


[-- Attachment #1.2: git-show-diff.patch --]
[-- Type: text/x-patch, Size: 1514 bytes --]

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;

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  6:55                     ` Martin Schlemmer
@ 2005-04-14  8:28                       ` Martin Schlemmer
  2005-04-14  8:38                         ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14  8:28 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


[-- Attachment #1.1: Type: text/plain, Size: 8317 bytes --]

On Thu, 2005-04-14 at 08:55 +0200, Martin Schlemmer wrote:
> On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:
> > 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.
> 
> > > > > 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?
> 
> > > > > 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>
> 

Ok, so I forgot to pull, and missed gitcancel.sh being added.
How about this one?  (One attached in case evo is brain dead and mangles
the tabs)

----

Normalize show-diff output, add --update-modes target to update-cache,
and make sure we only show real changes after changing the tracked
branch, as well as update the file modes according to the cache.

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

gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- gitcancel.sh
+++ gitcancel.sh        2005-04-14 10:26:49.000000000 +0200
@@ -12,7 +12,7 @@

 # FIXME: Does not revert mode changes!

-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged

 update-cache --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- gittrack.sh
+++ gittrack.sh 2005-04-14 10:26:49.000000000 +0200
@@ -51,6 +51,8 @@

        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       # --update-modes need to be before --refresh
+       update-cache --update-modes --refresh

 else
        [ "$tracking" ] || \
@@ -61,6 +63,8 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               # --update-modes need to be before --refresh
+               update-cache --update-modes --refresh

                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- show-diff.c
+++ show-diff.c 2005-04-14 10:26:49.000000000 +0200
@@ -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);
@@ -99,7 +104,7 @@
                        continue;

                new = read_sha1_file(ce->sha1, type, &size);
-               show_differences(ce->name, new, size);
+               show_differences(ce, new, size);
                free(new);
        }
        return 0;
update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
--- update-cache.c
+++ update-cache.c      2005-04-14 10:27:07.000000000 +0200
@@ -210,6 +210,39 @@
        }
 }

+static struct cache_entry *update_file_mode(struct cache_entry *ce)
+{
+       struct stat st;
+       int changed;
+
+       if (stat(ce->name, &st) < 0)
+               return NULL;
+
+       changed = cache_match_stat(ce, &st);
+       if (!changed)
+               return ce;
+
+       if (changed & MODE_CHANGED)
+               if (chmod(ce->name, ce->st_mode))
+                       return NULL;
+
+       return ce;
+}
+
+static void update_modes(void)
+{
+       int i;
+
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+
+               if (!update_file_mode(ce)) {
+                       printf("%s: needs update\n", ce->name);
+                       continue;
+               }
+       }
+}
+
 /*
  * We fundamentally don't like some paths: we don't want
  * dot or dot-dot anywhere, and in fact, we don't even want
@@ -282,6 +315,10 @@
                                refresh_cache();
                                continue;
                        }
+                       if (!strcmp(path, "--update-modes")) {
+                               update_modes();
+                               continue;
+                       }
                        die("unknown option %s", path);
                }
                if (!verify_path(path)) {



-- 
Martin Schlemmer


[-- Attachment #1.2: git-show-diff.patch --]
[-- Type: text/x-patch, Size: 3045 bytes --]

gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- gitcancel.sh
+++ gitcancel.sh	2005-04-14 10:26:49.000000000 +0200
@@ -12,7 +12,7 @@
 
 # FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged
 
 update-cache --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- gittrack.sh
+++ gittrack.sh	2005-04-14 10:26:49.000000000 +0200
@@ -51,6 +51,8 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	# --update-modes need to be before --refresh
+	update-cache --update-modes --refresh
 
 else
 	[ "$tracking" ] || \
@@ -61,6 +63,8 @@
 	if [ -s ".git/HEAD.local" ]; then
 		gitdiff.sh "$tracking" local | gitapply.sh
 		read-tree $(tree-id local)
+		# --update-modes need to be before --refresh
+		update-cache --update-modes --refresh
 
 		head=$(cat .git/HEAD)
 		branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- show-diff.c
+++ show-diff.c	2005-04-14 10:26:49.000000000 +0200
@@ -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);
@@ -99,7 +104,7 @@
 			continue;
 
 		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
+		show_differences(ce, new, size);
 		free(new);
 	}
 	return 0;
update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
--- update-cache.c
+++ update-cache.c	2005-04-14 10:27:07.000000000 +0200
@@ -210,6 +210,39 @@
 	}
 }
 
+static struct cache_entry *update_file_mode(struct cache_entry *ce)
+{
+	struct stat st;
+	int changed;
+
+	if (stat(ce->name, &st) < 0)
+		return NULL;
+
+	changed = cache_match_stat(ce, &st);
+	if (!changed)
+		return ce;
+
+	if (changed & MODE_CHANGED)
+		if (chmod(ce->name, ce->st_mode))
+			return NULL;
+
+	return ce;
+}
+
+static void update_modes(void)
+{
+	int i;
+
+	for (i = 0; i < active_nr; i++) {
+		struct cache_entry *ce = active_cache[i];
+
+		if (!update_file_mode(ce)) {
+			printf("%s: needs update\n", ce->name);
+			continue;
+		}
+	}
+}
+
 /*
  * We fundamentally don't like some paths: we don't want
  * dot or dot-dot anywhere, and in fact, we don't even want
@@ -282,6 +315,10 @@
 				refresh_cache();
 				continue;
 			}
+			if (!strcmp(path, "--update-modes")) {
+				update_modes();
+				continue;
+			}
 			die("unknown option %s", path);
 		}
 		if (!verify_path(path)) {

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  8:28                       ` Martin Schlemmer
@ 2005-04-14  8:38                         ` Martin Schlemmer
  2005-04-14  9:11                           ` Petr Baudis
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14  8:38 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


[-- Attachment #1.1: Type: text/plain, Size: 8842 bytes --]

On Thu, 2005-04-14 at 10:28 +0200, Martin Schlemmer wrote:
> On Thu, 2005-04-14 at 08:55 +0200, Martin Schlemmer wrote:
> > On Thu, 2005-04-14 at 00:19 +0200, Petr Baudis wrote:
> > > 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.
> > 
> > > > > > 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?
> > 
> > > > > > 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>
> > 
> 
> Ok, so I forgot to pull, and missed gitcancel.sh being added.
> How about this one?  (One attached in case evo is brain dead and mangles
> the tabs)
> 

Urk, forgot the update-cache in gitcancel.sh, and prefix is wrong.  I am
not sure this is needed for gitexport.sh though?

----

Normalize show-diff output, add --update-modes target to update-cache,
and make sure we only show real changes after changing the tracked
branch, as well as update the file modes according to the cache.

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

gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -12,7 +12,8 @@

 # FIXME: Does not revert mode changes!

-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged

-update-cache --refresh
+# --update-modes need to be before --refresh
+update-cache --update-modes --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,8 @@

        read-tree $(tree-id "$name")
        gitdiff.sh local "$name" | gitapply.sh
+       # --update-modes need to be before --refresh
+       update-cache --update-modes --refresh

 else
        [ "$tracking" ] || \
@@ -61,6 +63,8 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               # --update-modes need to be before --refresh
+               update-cache --update-modes --refresh

                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
@@ -99,7 +104,7 @@
                        continue;

                new = read_sha1_file(ce->sha1, type, &size);
-               show_differences(ce->name, new, size);
+               show_differences(ce, new, size);
                free(new);
        }
        return 0;
update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
--- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c
+++ uncommitted/update-cache.c
@@ -210,6 +210,39 @@
        }
 }

+static struct cache_entry *update_file_mode(struct cache_entry *ce)
+{
+       struct stat st;
+       int changed;
+
+       if (stat(ce->name, &st) < 0)
+               return NULL;
+
+       changed = cache_match_stat(ce, &st);
+       if (!changed)
+               return ce;
+
+       if (changed & MODE_CHANGED)
+               if (chmod(ce->name, ce->st_mode))
+                       return NULL;
+
+       return ce;
+}
+
+static void update_modes(void)
+{
+       int i;
+
+       for (i = 0; i < active_nr; i++) {
+               struct cache_entry *ce = active_cache[i];
+
+               if (!update_file_mode(ce)) {
+                       printf("%s: needs update\n", ce->name);
+                       continue;
+               }
+       }
+}
+
 /*
  * We fundamentally don't like some paths: we don't want
  * dot or dot-dot anywhere, and in fact, we don't even want
@@ -282,6 +315,10 @@
                                refresh_cache();
                                continue;
                        }
+                       if (!strcmp(path, "--update-modes")) {
+                               update_modes();
+                               continue;
+                       }
                        die("unknown option %s", path);
                }
                if (!verify_path(path)) {


-- 
Martin Schlemmer


[-- Attachment #1.2: git-show-diff.patch --]
[-- Type: text/x-patch, Size: 3200 bytes --]

gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -12,7 +12,8 @@
 
 # FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged
 
-update-cache --refresh
+# --update-modes need to be before --refresh
+update-cache --update-modes --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,8 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	# --update-modes need to be before --refresh
+	update-cache --update-modes --refresh
 
 else
 	[ "$tracking" ] || \
@@ -61,6 +63,8 @@
 	if [ -s ".git/HEAD.local" ]; then
 		gitdiff.sh "$tracking" local | gitapply.sh
 		read-tree $(tree-id local)
+		# --update-modes need to be before --refresh
+		update-cache --update-modes --refresh
 
 		head=$(cat .git/HEAD)
 		branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
@@ -99,7 +104,7 @@
 			continue;
 
 		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
+		show_differences(ce, new, size);
 		free(new);
 	}
 	return 0;
update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
--- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c
+++ uncommitted/update-cache.c
@@ -210,6 +210,39 @@
 	}
 }
 
+static struct cache_entry *update_file_mode(struct cache_entry *ce)
+{
+	struct stat st;
+	int changed;
+
+	if (stat(ce->name, &st) < 0)
+		return NULL;
+
+	changed = cache_match_stat(ce, &st);
+	if (!changed)
+		return ce;
+
+	if (changed & MODE_CHANGED)
+		if (chmod(ce->name, ce->st_mode))
+			return NULL;
+
+	return ce;
+}
+
+static void update_modes(void)
+{
+	int i;
+
+	for (i = 0; i < active_nr; i++) {
+		struct cache_entry *ce = active_cache[i];
+
+		if (!update_file_mode(ce)) {
+			printf("%s: needs update\n", ce->name);
+			continue;
+		}
+	}
+}
+
 /*
  * We fundamentally don't like some paths: we don't want
  * dot or dot-dot anywhere, and in fact, we don't even want
@@ -282,6 +315,10 @@
 				refresh_cache();
 				continue;
 			}
+			if (!strcmp(path, "--update-modes")) {
+				update_modes();
+				continue;
+			}
 			die("unknown option %s", path);
 		}
 		if (!verify_path(path)) {

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  8:38                         ` Martin Schlemmer
@ 2005-04-14  9:11                           ` Petr Baudis
  2005-04-14  9:40                             ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Petr Baudis @ 2005-04-14  9:11 UTC (permalink / raw)
  To: Martin Schlemmer; +Cc: git

Please trim the replied mails a bit, snipping old and irrelevant parts.
This is insane. :-)

Dear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
..snip..
> Normalize show-diff output, add --update-modes target to update-cache,
> and make sure we only show real changes after changing the tracked
> branch, as well as update the file modes according to the cache.

I'm lost. Why do you do --update-modes? That makes no sense to me.
You introduce them to the cache out-of-order w.r.t. commits, that means
in the normal git usage they are already unrevertable.

What are you trying to do? Mode changes _are_ real changes. You _don't_
want to silence them. What you want is to even show them more explicitly
in show-diff.

The --refreshes are fine.

> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> 
> gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
> --- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
> +++ uncommitted/gitcancel.sh
> @@ -12,7 +12,8 @@
> 
>  # FIXME: Does not revert mode changes!
> 
> -show-diff | patch -p0 -R
> +show-diff | patch -p1 -R
>  rm -f .git/add-queue .git/rm-queue .git/merged
> 
> -update-cache --refresh
> +# --update-modes need to be before --refresh
> +update-cache --update-modes --refresh

Here, e.g., you should do the very opposite - change the modes back to
how are they in the cache.

> show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);

The "directory" sha1 is the sha1 of the tree, not of the particular
file - that one is in the "attributes" list (parentheses after the
filename), together with mode.

>         f = popen(cmd, "w");
>         if (old_size)
>                 fwrite(old_contents, old_size, 1, f);
> @@ -99,7 +104,7 @@
>                         continue;
> 
>                 new = read_sha1_file(ce->sha1, type, &size);
> -               show_differences(ce->name, new, size);
> +               show_differences(ce, new, size);
>                 free(new);
>         }
>         return 0;
> update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
> --- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c
> +++ uncommitted/update-cache.c
> @@ -210,6 +210,39 @@
>         }
>  }
> 
> +static struct cache_entry *update_file_mode(struct cache_entry *ce)
> +{
> +       struct stat st;
> +       int changed;
> +
> +       if (stat(ce->name, &st) < 0)
> +               return NULL;
> +
> +       changed = cache_match_stat(ce, &st);
> +       if (!changed)
> +               return ce;
> +
> +       if (changed & MODE_CHANGED)
> +               if (chmod(ce->name, ce->st_mode))
> +                       return NULL;
> +
> +       return ce;
> +}
> +
> +static void update_modes(void)
> +{
> +       int i;
> +
> +       for (i = 0; i < active_nr; i++) {
> +               struct cache_entry *ce = active_cache[i];
> +
> +               if (!update_file_mode(ce)) {
> +                       printf("%s: needs update\n", ce->name);
> +                       continue;
> +               }
> +       }
> +}
> +
>  /*
>   * We fundamentally don't like some paths: we don't want
>   * dot or dot-dot anywhere, and in fact, we don't even want

Oh. So you are actually doing the _opposite_! But that's very wrong too.
update-cache is for the direction tree -> index. For the opposite
direction, you should use checkout-cache.

> @@ -282,6 +315,10 @@
>                                 refresh_cache();
>                                 continue;
>                         }
> +                       if (!strcmp(path, "--update-modes")) {
> +                               update_modes();
> +                               continue;
> +                       }
>                         die("unknown option %s", path);
>                 }
>                 if (!verify_path(path)) {
> 
> 
> -- 
> Martin Schlemmer
> 





-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  9:11                           ` Petr Baudis
@ 2005-04-14  9:40                             ` Martin Schlemmer
  2005-04-14  9:55                               ` Martin Schlemmer
  2005-04-14 22:42                               ` Petr Baudis
  0 siblings, 2 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14  9:40 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 7340 bytes --]

(PS, can you check the fact that your mail client keeps on adding a 'Re:
' ...)

On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:
> Please trim the replied mails a bit, snipping old and irrelevant parts.
> This is insane. :-)
> 
> Dear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> ..snip..
> > Normalize show-diff output, add --update-modes target to update-cache,
> > and make sure we only show real changes after changing the tracked
> > branch, as well as update the file modes according to the cache.
> 
> I'm lost. Why do you do --update-modes? That makes no sense to me.
> You introduce them to the cache out-of-order w.r.t. commits, that means
> in the normal git usage they are already unrevertable.
> 

Right, afterwards I thought I did add it to the wrong place.


> What are you trying to do? Mode changes _are_ real changes. You _don't_
> want to silence them. What you want is to even show them more explicitly
> in show-diff.
> 

No, you do not understand.  If you actually change the mode, it will
show.  What now happens, is that say I track the 'linus' branch, then
untrack, and then track 'pasky' again, the Patches will be applied, but
not the mode changes which are stored in the cache ...  Let me show you:

-----
$ ls -l $(./show-diff -s | cut -d: -f1)
-rw-r--r--  1 root root  168 Apr 14 11:33 commit-id
-rw-r--r--  1 root root 2213 Apr 14 11:33 git
-rw-r--r--  1 root root 1168 Apr 14 11:33 gitXnormid.sh
-rw-r--r--  1 root root  403 Apr 14 11:33 gitadd.sh
-rw-r--r--  1 root root  844 Apr 14 11:33 gitaddremote.sh
-rw-r--r--  1 root root 1899 Apr 14 11:33 gitapply.sh
-rw-r--r--  1 root root  479 Apr 14 11:33 gitcancel.sh
-rw-r--r--  1 root root 2512 Apr 14 11:33 gitcommit.sh
-rw-r--r--  1 root root 2152 Apr 14 11:33 gitdiff-do
-rw-r--r--  1 root root  819 Apr 14 11:33 gitdiff.sh
-rw-r--r--  1 root root  717 Apr 14 11:33 gitexport.sh
-rw-r--r--  1 root root  524 Apr 14 11:33 gitlog.sh
-rw-r--r--  1 root root  228 Apr 14 11:33 gitls.sh
-rw-r--r--  1 root root  904 Apr 14 11:33 gitlsobj.sh
-rw-r--r--  1 root root  665 Apr 14 11:33 gitmerge.sh
-rw-r--r--  1 root root 2044 Apr 14 11:33 gitpull.sh
-rw-r--r--  1 root root  433 Apr 14 11:33 gitrm.sh
-rw-r--r--  1 root root  614 Apr 14 11:33 gittag.sh
-rw-r--r--  1 root root 2272 Apr 14 11:33 gittrack.sh
-rw-r--r--  1 root root  284 Apr 14 11:33 parent-id
-rw-r--r--  1 root root  177 Apr 14 11:33 tree-id
-----

(Note no 'x' bit ...)

And that is _after_ doing:

 $ git track linus; git track

So basically the modes that are stored in the cache are not applied ...
Although, yes, I prob should add the relevant code to checkout-cache.

> The --refreshes are fine.
> 
> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > 
> > gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
> > --- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
> > +++ uncommitted/gitcancel.sh
> > @@ -12,7 +12,8 @@
> > 
> >  # FIXME: Does not revert mode changes!
> > 
> > -show-diff | patch -p0 -R
> > +show-diff | patch -p1 -R
> >  rm -f .git/add-queue .git/rm-queue .git/merged
> > 
> > -update-cache --refresh
> > +# --update-modes need to be before --refresh
> > +update-cache --update-modes --refresh
> 
> Here, e.g., you should do the very opposite - change the modes back to
> how are they in the cache.
> 

Uhm, that is what it did ...  Like I said above, the wrong place though
to add the code to update-cache.

> > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
> 
> The "directory" sha1 is the sha1 of the tree, not of the particular
> file - that one is in the "attributes" list (parentheses after the
> filename), together with mode.
> 

Does it really matter?  It is more just to get the patch prefix right,
and I did it as it went nicely with the printed:

----
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
----

for example ...

> >         f = popen(cmd, "w");
> >         if (old_size)
> >                 fwrite(old_contents, old_size, 1, f);
> > @@ -99,7 +104,7 @@
> >                         continue;
> > 
> >                 new = read_sha1_file(ce->sha1, type, &size);
> > -               show_differences(ce->name, new, size);
> > +               show_differences(ce, new, size);
> >                 free(new);
> >         }
> >         return 0;
> > update-cache.c:  62d0a6c41560d40863c44599355af10d9e089312
> > --- 62d0a6c41560d40863c44599355af10d9e089312/update-cache.c
> > +++ uncommitted/update-cache.c
> > @@ -210,6 +210,39 @@
> >         }
> >  }
> > 
> > +static struct cache_entry *update_file_mode(struct cache_entry *ce)
> > +{
> > +       struct stat st;
> > +       int changed;
> > +
> > +       if (stat(ce->name, &st) < 0)
> > +               return NULL;
> > +
> > +       changed = cache_match_stat(ce, &st);
> > +       if (!changed)
> > +               return ce;
> > +
> > +       if (changed & MODE_CHANGED)
> > +               if (chmod(ce->name, ce->st_mode))
> > +                       return NULL;
> > +
> > +       return ce;
> > +}
> > +
> > +static void update_modes(void)
> > +{
> > +       int i;
> > +
> > +       for (i = 0; i < active_nr; i++) {
> > +               struct cache_entry *ce = active_cache[i];
> > +
> > +               if (!update_file_mode(ce)) {
> > +                       printf("%s: needs update\n", ce->name);
> > +                       continue;
> > +               }
> > +       }
> > +}
> > +
> >  /*
> >   * We fundamentally don't like some paths: we don't want
> >   * dot or dot-dot anywhere, and in fact, we don't even want
> 
> Oh. So you are actually doing the _opposite_! But that's very wrong too.
> update-cache is for the direction tree -> index. For the opposite
> direction, you should use checkout-cache.
> 

Right, will do.

> > @@ -282,6 +315,10 @@
> >                                 refresh_cache();
> >                                 continue;
> >                         }
> > +                       if (!strcmp(path, "--update-modes")) {
> > +                               update_modes();
> > +                               continue;
> > +                       }
> >                         die("unknown option %s", path);
> >                 }
> >                 if (!verify_path(path)) {
> > 
> > 
> > -- 
> > Martin Schlemmer
> > 
> 


-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  9:40                             ` Martin Schlemmer
@ 2005-04-14  9:55                               ` Martin Schlemmer
  2005-04-14 22:35                                 ` Alex Riesen
  2005-04-14 22:42                               ` Petr Baudis
  1 sibling, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14  9:55 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git


[-- Attachment #1.1: Type: text/plain, Size: 5242 bytes --]

On Thu, 2005-04-14 at 11:40 +0200, Martin Schlemmer wrote:
> On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:
> > Please trim the replied mails a bit, snipping old and irrelevant parts.
> > This is insane. :-)
> > 
> > Dear diary, on Thu, Apr 14, 2005 at 10:38:25AM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > ..snip..
> > > Normalize show-diff output, add --update-modes target to update-cache,
> > > and make sure we only show real changes after changing the tracked
> > > branch, as well as update the file modes according to the cache.
> > 
> > I'm lost. Why do you do --update-modes? That makes no sense to me.
> > You introduce them to the cache out-of-order w.r.t. commits, that means
> > in the normal git usage they are already unrevertable.
> > 
> 
> Right, afterwards I thought I did add it to the wrong place.
> 
> 
> > What are you trying to do? Mode changes _are_ real changes. You _don't_
> > want to silence them. What you want is to even show them more explicitly
> > in show-diff.
> > 
> 
> No, you do not understand.  If you actually change the mode, it will
> show.  What now happens, is that say I track the 'linus' branch, then
> untrack, and then track 'pasky' again, the Patches will be applied, but
> not the mode changes which are stored in the cache ...
>
> So basically the modes that are stored in the cache are not applied ...
> Although, yes, I prob should add the relevant code to checkout-cache.
> 

Ok, this should be a better one I think.

----

Normalize show-diff output, add --update-modes target to update-cache,
and make sure we only show real changes after changing the tracked
branch, as well as update the file modes according to the cache.

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

checkout-cache.c:  f06871cdbc1b18ea93bdf4e17126aeb4cca1373e
--- f06871cdbc1b18ea93bdf4e17126aeb4cca1373e/checkout-cache.c
+++ uncommitted/checkout-cache.c
@@ -34,7 +34,7 @@
  */
 #include "cache.h"

-static int force = 0, quiet = 0;
+static int force = 0, quiet = 0, update_mode = 0;

 static void create_directories(const char *path)
 {
@@ -99,6 +99,8 @@
                unsigned changed = cache_match_stat(ce, &st);
                if (!changed)
                        return 0;
+               if (update_mode && changed & MODE_CHANGED)
+                       chmod(ce->name, ce->st_mode);
                if (!force) {
                        if (!quiet)
                                fprintf(stderr, "checkout-cache: %s already exists\n", ce->name);
@@ -158,6 +160,10 @@
                                quiet = 1;
                                continue;
                        }
+                       if (!strcmp(arg, "-m")) {
+                               update_mode = 1;
+                               continue;
+                       }
                }
                checkout_file(arg);
        }
gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -12,7 +12,8 @@

 # FIXME: Does not revert mode changes!

-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged

+checkout-cache -q -m -a
 update-cache --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,8 @@

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

 else
        [ "$tracking" ] || \
@@ -61,6 +63,8 @@
        if [ -s ".git/HEAD.local" ]; then
                gitdiff.sh "$tracking" local | gitapply.sh
                read-tree $(tree-id local)
+               checkout-cache -q -m -a
+               update-cache --refresh

                head=$(cat .git/HEAD)
                branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
@@ -99,7 +104,7 @@
                        continue;

                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


[-- Attachment #1.2: git-show-diff.patch --]
[-- Type: text/x-patch, Size: 2745 bytes --]

checkout-cache.c:  f06871cdbc1b18ea93bdf4e17126aeb4cca1373e
--- f06871cdbc1b18ea93bdf4e17126aeb4cca1373e/checkout-cache.c
+++ uncommitted/checkout-cache.c
@@ -34,7 +34,7 @@
  */
 #include "cache.h"
 
-static int force = 0, quiet = 0;
+static int force = 0, quiet = 0, update_mode = 0;
 
 static void create_directories(const char *path)
 {
@@ -99,6 +99,8 @@
 		unsigned changed = cache_match_stat(ce, &st);
 		if (!changed)
 			return 0;
+		if (update_mode && changed & MODE_CHANGED)
+			chmod(ce->name, ce->st_mode);
 		if (!force) {
 			if (!quiet)
 				fprintf(stderr, "checkout-cache: %s already exists\n", ce->name);
@@ -158,6 +160,10 @@
 				quiet = 1;
 				continue;
 			}
+			if (!strcmp(arg, "-m")) {
+				update_mode = 1;
+				continue;
+			}
 		}
 		checkout_file(arg);
 	}
gitcancel.sh:  ec58f7444a42cd3cbaae919fc68c70a3866420c0
--- ec58f7444a42cd3cbaae919fc68c70a3866420c0/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -12,7 +12,8 @@
 
 # FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
+show-diff | patch -p1 -R
 rm -f .git/add-queue .git/rm-queue .git/merged
 
+checkout-cache -q -m -a
 update-cache --refresh
gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,8 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	checkout-cache -q -m -a
+	update-cache --refresh
 
 else
 	[ "$tracking" ] || \
@@ -61,6 +63,8 @@
 	if [ -s ".git/HEAD.local" ]; then
 		gitdiff.sh "$tracking" local | gitapply.sh
 		read-tree $(tree-id local)
+		checkout-cache -q -m -a
+		update-cache --refresh
 
 		head=$(cat .git/HEAD)
 		branchhead=$(cat .git/heads/$tracking)
show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
--- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
@@ -99,7 +104,7 @@
 			continue;
 
 		new = read_sha1_file(ce->sha1, type, &size);
-		show_differences(ce->name, new, size);
+		show_differences(ce, new, size);
 		free(new);
 	}
 	return 0;

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14  9:55                               ` Martin Schlemmer
@ 2005-04-14 22:35                                 ` Alex Riesen
  2005-04-15  5:45                                   ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Alex Riesen @ 2005-04-14 22:35 UTC (permalink / raw)
  To: azarah; +Cc: Petr Baudis, git

On 4/14/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:
> +               if (update_mode && changed & MODE_CHANGED)
> +                       chmod(ce->name, ce->st_mode);

it's "if ((update_mode && changed) & MODE_CHANGED)"
Did you really mean that?

-alex

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-14  9:40                             ` Martin Schlemmer
  2005-04-14  9:55                               ` Martin Schlemmer
@ 2005-04-14 22:42                               ` Petr Baudis
  2005-04-14 23:01                                 ` Martin Schlemmer
  1 sibling, 1 reply; 16+ messages in thread
From: Petr Baudis @ 2005-04-14 22:42 UTC (permalink / raw)
  To: Martin Schlemmer; +Cc: git

Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> (PS, can you check the fact that your mail client keeps on adding a 'Re:
> ' ...)

Hmm. I guess my ancient reply_regexp
"^((\\[|\\()([^B]|B([^u]|u([^g]|g([^ ]|AnTiMaTcH))))[^]]+(\\]|\\)))?[
 \t]*((re([\\[0-9\\]+])*|aw):[ \t]*)?" is broken... ;-)

> On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:
> > I'm lost. Why do you do --update-modes? That makes no sense to me.
> > You introduce them to the cache out-of-order w.r.t. commits, that means
> > in the normal git usage they are already unrevertable.
> > 
> 
> Right, afterwards I thought I did add it to the wrong place.

So, could you please do something with it? :-)

> > What are you trying to do? Mode changes _are_ real changes. You _don't_
> > want to silence them. What you want is to even show them more explicitly
> > in show-diff.
> > 
> 
> No, you do not understand.  If you actually change the mode, it will
> show.  What now happens, is that say I track the 'linus' branch, then
> untrack, and then track 'pasky' again, the Patches will be applied, but
> not the mode changes which are stored in the cache ...  Let me show you:
> 
> -----
> $ ls -l $(./show-diff -s | cut -d: -f1)
..directroy listing with no 'x' bit..
> -----
> 
> (Note no 'x' bit ...)
> 
> And that is _after_ doing:
> 
>  $ git track linus; git track
> 
> So basically the modes that are stored in the cache are not applied ...
> Although, yes, I prob should add the relevant code to checkout-cache.

This should be fixed now, BTW. git apply didn't correctly apply the
mode changes, but now it should. Several bugs prevented it to, in fact.
;-)

> > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
> > 
> > The "directory" sha1 is the sha1 of the tree, not of the particular
> > file - that one is in the "attributes" list (parentheses after the
> > filename), together with mode.
> > 
> 
> Does it really matter?  It is more just to get the patch prefix right,
> and I did it as it went nicely with the printed:
> 
> ----
> show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> ----
> 
> for example ...

Yes, it matters, and I don't care how nicely it wents with what you
print before.

Either print there some nonsense which is clear not to be a tree ID, or
(much more preferably) print the real tree ID there. If some tool ever
uses it (e.g. to help resolve conflicts, perhaps even actually doing a
real merge based on the patch), you just confused it.

Also, do you think you could separate this patch from the other
(--update-modes) patch? (If we actually still need the --update-modes
patch after git apply was fixed.)

Thanks,

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-14 23:01                                 ` Martin Schlemmer
@ 2005-04-14 23:00                                   ` Petr Baudis
  2005-04-14 23:09                                     ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Petr Baudis @ 2005-04-14 23:00 UTC (permalink / raw)
  To: Martin Schlemmer; +Cc: git

Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:
> > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > So basically the modes that are stored in the cache are not applied ...
> > > Although, yes, I prob should add the relevant code to checkout-cache.
> > 
> > This should be fixed now, BTW. git apply didn't correctly apply the
> > mode changes, but now it should. Several bugs prevented it to, in fact.
> > ;-)
> 
> Yep, I saw - thought you scrapped this, so mailed a new patch (or was
> busy doing the touch ups to the email when this came in.

Hmm, I must've missed the new patch. The latest I have still puts the
stuff to update-cache and combines it with the show-diff change.

> > > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/show-diff.c
> > > > > +++ uncommitted/show-diff.c
> > > > > @@ -5,13 +5,18 @@
..snip..
> > > > > -       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);
> > > > 
> > > > The "directory" sha1 is the sha1 of the tree, not of the particular
> > > > file - that one is in the "attributes" list (parentheses after the
> > > > filename), together with mode.
> > > > 
> > > 
> > > Does it really matter?  It is more just to get the patch prefix right,
> > > and I did it as it went nicely with the printed:
> > > 
> > > ----
> > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > ----
> > > 
> > > for example ...
> > 
> > Yes, it matters, and I don't care how nicely it wents with what you
> > print before.
> > 
> 
> hah ;p
> 
> > Either print there some nonsense which is clear not to be a tree ID, or
> > (much more preferably) print the real tree ID there. If some tool ever
> > uses it (e.g. to help resolve conflicts, perhaps even actually doing a
> > real merge based on the patch), you just confused it.
> > 
> 
> Ok, understood.  Do you think it will be scripted?  If not I guess we
> can just do labels like:
> 
> --- committed/
> +++ uncommitted/
> 
> ?

Heh. Well, of course this could do. But is there any technical reason
why not just carry the sha1 id of the tree around and stuff it there?

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-14 22:42                               ` Petr Baudis
@ 2005-04-14 23:01                                 ` Martin Schlemmer
  2005-04-14 23:00                                   ` Petr Baudis
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14 23:01 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 4262 bytes --]

On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:
> Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > (PS, can you check the fact that your mail client keeps on adding a 'Re:
> > ' ...)
> 
> Hmm. I guess my ancient reply_regexp
> "^((\\[|\\()([^B]|B([^u]|u([^g]|g([^ ]|AnTiMaTcH))))[^]]+(\\]|\\)))?[
>  \t]*((re([\\[0-9\\]+])*|aw):[ \t]*)?" is broken... ;-)
> 
> > On Thu, 2005-04-14 at 11:11 +0200, Petr Baudis wrote:
> > > I'm lost. Why do you do --update-modes? That makes no sense to me.
> > > You introduce them to the cache out-of-order w.r.t. commits, that means
> > > in the normal git usage they are already unrevertable.
> > > 
> > 
> > Right, afterwards I thought I did add it to the wrong place.
> 
> So, could you please do something with it? :-)
> 
> > > What are you trying to do? Mode changes _are_ real changes. You _don't_
> > > want to silence them. What you want is to even show them more explicitly
> > > in show-diff.
> > > 
> > 
> > No, you do not understand.  If you actually change the mode, it will
> > show.  What now happens, is that say I track the 'linus' branch, then
> > untrack, and then track 'pasky' again, the Patches will be applied, but
> > not the mode changes which are stored in the cache ...  Let me show you:
> > 
> > -----
> > $ ls -l $(./show-diff -s | cut -d: -f1)
> ..directroy listing with no 'x' bit..
> > -----
> > 
> > (Note no 'x' bit ...)
> > 
> > And that is _after_ doing:
> > 
> >  $ git track linus; git track
> > 
> > So basically the modes that are stored in the cache are not applied ...
> > Although, yes, I prob should add the relevant code to checkout-cache.
> 
> This should be fixed now, BTW. git apply didn't correctly apply the
> mode changes, but now it should. Several bugs prevented it to, in fact.
> ;-)
> 

Yep, I saw - thought you scrapped this, so mailed a new patch (or was
busy doing the touch ups to the email when this came in.

> > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > > --- a531ca4078525d1c8dcf84aae0bfa89fed6e5d96/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);
> > > 
> > > The "directory" sha1 is the sha1 of the tree, not of the particular
> > > file - that one is in the "attributes" list (parentheses after the
> > > filename), together with mode.
> > > 
> > 
> > Does it really matter?  It is more just to get the patch prefix right,
> > and I did it as it went nicely with the printed:
> > 
> > ----
> > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > ----
> > 
> > for example ...
> 
> Yes, it matters, and I don't care how nicely it wents with what you
> print before.
> 

hah ;p

> Either print there some nonsense which is clear not to be a tree ID, or
> (much more preferably) print the real tree ID there. If some tool ever
> uses it (e.g. to help resolve conflicts, perhaps even actually doing a
> real merge based on the patch), you just confused it.
> 

Ok, understood.  Do you think it will be scripted?  If not I guess we
can just do labels like:

--- committed/
+++ uncommitted/

?

> Also, do you think you could separate this patch from the other
> (--update-modes) patch? (If we actually still need the --update-modes
> patch after git apply was fixed.)
> 

Yeah, already split it out locally, just waiting on above response ...


Thanks,

-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-14 23:00                                   ` Petr Baudis
@ 2005-04-14 23:09                                     ` Martin Schlemmer
  2005-04-14 23:25                                       ` Martin Schlemmer
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14 23:09 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2237 bytes --]

On Fri, 2005-04-15 at 01:00 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:
> > > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter
> > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > > > > -       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);
> > > > > 
> > > > > The "directory" sha1 is the sha1 of the tree, not of the particular
> > > > > file - that one is in the "attributes" list (parentheses after the
> > > > > filename), together with mode.
> > > > > 
> > > > 
> > > > Does it really matter?  It is more just to get the patch prefix right,
> > > > and I did it as it went nicely with the printed:
> > > > 
> > > > ----
> > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > > ----
> > > > 
> > > > for example ...
> > > 
> > > Yes, it matters, and I don't care how nicely it wents with what you
> > > print before.
> > > 
> > 
> > hah ;p
> > 
> > > Either print there some nonsense which is clear not to be a tree ID, or
> > > (much more preferably) print the real tree ID there. If some tool ever
> > > uses it (e.g. to help resolve conflicts, perhaps even actually doing a
> > > real merge based on the patch), you just confused it.
> > > 
> > 
> > Ok, understood.  Do you think it will be scripted?  If not I guess we
> > can just do labels like:
> > 
> > --- committed/
> > +++ uncommitted/
> > 
> > ?
> 
> Heh. Well, of course this could do. But is there any technical reason
> why not just carry the sha1 id of the tree around and stuff it there?
> 

Not at all. Just wanted to know if anybody saw the possible use before
adding possible cruft that could be done shorter - will do a patch
shortly.


Thanks,

-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-14 23:09                                     ` Martin Schlemmer
@ 2005-04-14 23:25                                       ` Martin Schlemmer
  0 siblings, 0 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-14 23:25 UTC (permalink / raw)
  To: Petr Baudis; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2551 bytes --]

On Fri, 2005-04-15 at 01:09 +0200, Martin Schlemmer wrote:
> On Fri, 2005-04-15 at 01:00 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, Apr 15, 2005 at 01:01:27AM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > On Fri, 2005-04-15 at 00:42 +0200, Petr Baudis wrote:
> > > > Dear diary, on Thu, Apr 14, 2005 at 11:40:09AM CEST, I got a letter
> > > > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > > > > > -       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);
> > > > > > 
> > > > > > The "directory" sha1 is the sha1 of the tree, not of the particular
> > > > > > file - that one is in the "attributes" list (parentheses after the
> > > > > > filename), together with mode.
> > > > > > 
> > > > > 
> > > > > Does it really matter?  It is more just to get the patch prefix right,
> > > > > and I did it as it went nicely with the printed:
> > > > > 
> > > > > ----
> > > > > show-diff.c:  a531ca4078525d1c8dcf84aae0bfa89fed6e5d96
> > > > > ----
> > > > > 
> > > > > for example ...
> > > > 
> > > > Yes, it matters, and I don't care how nicely it wents with what you
> > > > print before.
> > > > 
> > > 
> > > hah ;p
> > > 
> > > > Either print there some nonsense which is clear not to be a tree ID, or
> > > > (much more preferably) print the real tree ID there. If some tool ever
> > > > uses it (e.g. to help resolve conflicts, perhaps even actually doing a
> > > > real merge based on the patch), you just confused it.
> > > > 
> > > 
> > > Ok, understood.  Do you think it will be scripted?  If not I guess we
> > > can just do labels like:
> > > 
> > > --- committed/
> > > +++ uncommitted/
> > > 
> > > ?
> > 
> > Heh. Well, of course this could do. But is there any technical reason
> > why not just carry the sha1 id of the tree around and stuff it there?
> > 
> 
> Not at all. Just wanted to know if anybody saw the possible use before
> adding possible cruft that could be done shorter - will do a patch
> shortly.
> 

Ho hum - none of the lowlevel tools know or work with the tree-id, and I
am not too sure if Linus will like adding something to get it ... any
ideas?


-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-14 22:35                                 ` Alex Riesen
@ 2005-04-15  5:45                                   ` Martin Schlemmer
  2005-04-15  6:42                                     ` Paul Jackson
  2005-04-15 23:49                                     ` Re: Re: " Alex Riesen
  0 siblings, 2 replies; 16+ messages in thread
From: Martin Schlemmer @ 2005-04-15  5:45 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Petr Baudis, git

[-- Attachment #1: Type: text/plain, Size: 1991 bytes --]

On Fri, 2005-04-15 at 00:35 +0200, Alex Riesen wrote:
> On 4/14/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:
> > +               if (update_mode && changed & MODE_CHANGED)
> > +                       chmod(ce->name, ce->st_mode);
> 
> it's "if ((update_mode && changed) & MODE_CHANGED)"
> Did you really mean that?
> 

No, '&' have a higher priority (weight?) than '&&'.  Although, yes, it
might be better style to add brackets.

But just to make you happy, let me prove it:

-----
$ cat foo1.c
int main() {
        int foo, bar;

        if (foo && bar & 1)
                return 1;

        return 0;
}
$ cat foo2.c
int main() {
        int foo, bar;

        if (foo && (bar & 1))
                return 1;

        return 0;
}
$ cat foo3.c
int main() {
        int foo, bar;

        if ((foo && bar) & 1)
                return 1;

        return 0;
}
$ gcc -c -S foo1.c -o foo1.S
$ gcc -c -S foo2.c -o foo2.S
$ gcc -c -S foo3.c -o foo3.S
$ diff -u foo1.S foo2.S
--- foo1.S      2005-04-15 07:42:27.000000000 +0200
+++ foo2.S      2005-04-15 07:42:32.000000000 +0200
@@ -1,4 +1,4 @@
-       .file   "foo1.c"
+       .file   "foo2.c"
        .text
 .globl main
        .type   main, @function
$ diff -u foo1.S foo3.S
--- foo1.S      2005-04-15 07:42:27.000000000 +0200
+++ foo3.S      2005-04-15 07:42:35.000000000 +0200
@@ -1,4 +1,4 @@
-       .file   "foo1.c"
+       .file   "foo3.c"
        .text
 .globl main
        .type   main, @function
@@ -9,9 +9,14 @@
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
+       movl    $0, -16(%ebp)
        cmpl    $0, -4(%ebp)
-       je      .L2
-       movl    -8(%ebp), %eax
+       je      .L3
+       cmpl    $0, -8(%ebp)
+       je      .L3
+       movl    $1, -16(%ebp)
+.L3:
+       movl    -16(%ebp), %eax
        andl    $1, %eax
        testl   %eax, %eax
        je      .L2
-----


-- 
Martin Schlemmer


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Remove need to untrack before tracking new branch
  2005-04-15  5:45                                   ` Martin Schlemmer
@ 2005-04-15  6:42                                     ` Paul Jackson
  2005-04-15 23:49                                     ` Re: Re: " Alex Riesen
  1 sibling, 0 replies; 16+ messages in thread
From: Paul Jackson @ 2005-04-15  6:42 UTC (permalink / raw)
  To: azarah; +Cc: raa.lkml, pasky, git

> No, '&' have a higher priority (weight?) than '&&'.

& has a higher precedence than &&

  C Operator Precedence and Associativity
  http://www.difranco.net/cop2220/op-prec.htm

and many others -- google for 'c operator precedence'

Where the bitops &, | and ^ bite you is that they are
lower precedence than many other ops, including '=='.

-- 
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <pj@engr.sgi.com> 1.650.933.1373, 1.925.600.0401

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Re: Re: Re: Remove need to untrack before tracking new branch
  2005-04-15  5:45                                   ` Martin Schlemmer
  2005-04-15  6:42                                     ` Paul Jackson
@ 2005-04-15 23:49                                     ` Alex Riesen
  1 sibling, 0 replies; 16+ messages in thread
From: Alex Riesen @ 2005-04-15 23:49 UTC (permalink / raw)
  To: azarah; +Cc: Petr Baudis, git

On 4/15/05, Martin Schlemmer <azarah@nosferatu.za.org> wrote:
> > > +               if (update_mode && changed & MODE_CHANGED)
> > > +                       chmod(ce->name, ce->st_mode);
> >
> > it's "if ((update_mode && changed) & MODE_CHANGED)"
> > Did you really mean that?
> 
> No, '&' have a higher priority (weight?) than '&&'.  Although, yes, it
> might be better style to add brackets.

I wasn't concerned about style

> But just to make you happy, let me prove it:

It's not to make me happy, it's just to prove you're right.
You did it, I stand corrected.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-04-15 23:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20050411135758.GA3524@pasky.ji.cz>
     [not found] ` <1113310045.23299.15.camel@nosferatu.lan>
     [not found]   ` <20050412130250.GG22614@pasky.ji.cz>
     [not found]     ` <1113311595.23299.17.camel@nosferatu.lan>
     [not found]       ` <20050412132307.GH22614@pasky.ji.cz>
     [not found]         ` <1113375277.23299.25.camel@nosferatu.lan>
     [not found]           ` <20050413075441.GD16489@pasky.ji.cz>
     [not found]             ` <1113381672.23299.47.camel@nosferatu.lan>
     [not found]               ` <20050413092656.GO16489@pasky.ji.cz>
     [not found]                 ` <1113394537.23299.51.camel@nosferatu.lan>
2005-04-13 22:19                   ` Re: Re: Remove need to untrack before tracking new branch Petr Baudis
2005-04-14  6:55                     ` Martin Schlemmer
2005-04-14  8:28                       ` Martin Schlemmer
2005-04-14  8:38                         ` Martin Schlemmer
2005-04-14  9:11                           ` Petr Baudis
2005-04-14  9:40                             ` Martin Schlemmer
2005-04-14  9:55                               ` Martin Schlemmer
2005-04-14 22:35                                 ` Alex Riesen
2005-04-15  5:45                                   ` Martin Schlemmer
2005-04-15  6:42                                     ` Paul Jackson
2005-04-15 23:49                                     ` Re: Re: " Alex Riesen
2005-04-14 22:42                               ` Petr Baudis
2005-04-14 23:01                                 ` Martin Schlemmer
2005-04-14 23:00                                   ` Petr Baudis
2005-04-14 23:09                                     ` Martin Schlemmer
2005-04-14 23:25                                       ` Martin Schlemmer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).