# [patch pasky] update gitcancel.sh to handle modes as well

7 messages from 2005-04-14 to 2005-04-14. Participants: Martin Schlemmer, Petr Baudis.
Thread: https://gitlist.dev/t/28

## Petr Baudis, 2005-04-14 22:57

Subject: Re: update gitcancel.sh to handle modes as well
Message-ID: <20050414225722.GR22699@pasky.ji.cz>
URL: https://gitlist.dev/e/20050414225722.GR22699%40pasky.ji.cz
In-Reply-To: <1113519445.23299.119.camel@nosferatu.lan>

```
Dear diary, on Fri, Apr 15, 2005 at 12:57:25AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Hi,
> 
> gitcancel.sh do not handle mode changes:
> 
> ----
> $ chmod -x Makefile
> $ git cancel
> patch: **** Only garbage was found in the patch input.
> ----
> 
> Rather use checkout-cache to sync our tree, as should do the right thing
> instead of diffing (cancel imply just blow away everything).
> 
> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> 
> gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
> --- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
> +++ uncommitted/gittrack.sh
> @@ -51,6 +51,7 @@
> 
>         read-tree $(tree-id "$name")
>         gitdiff.sh local "$name" | gitapply.sh
> +       update-cache --refresh
> 
>  else
>         [ "$tracking" ] || \
> @@ -61,6 +62,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/heads/$tracking)

The patch looks familiar, but not right. ;-)

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

```

## Martin Schlemmer, 2005-04-14 22:57

Subject: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <1113519445.23299.119.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113519445.23299.119.camel%40nosferatu.lan

```
Hi,

gitcancel.sh do not handle mode changes:

----
$ chmod -x Makefile
$ git cancel
patch: **** Only garbage was found in the patch input.
----

Rather use checkout-cache to sync our tree, as should do the right thing
instead of diffing (cancel imply just blow away everything).

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

gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,7 @@

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

 else
        [ "$tracking" ] || \
@@ -61,6 +62,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/heads/$tracking)


-- 
Martin Schlemmer



gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
--- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
+++ uncommitted/gittrack.sh
@@ -51,6 +51,7 @@
 
 	read-tree $(tree-id "$name")
 	gitdiff.sh local "$name" | gitapply.sh
+	update-cache --refresh
 
 else
 	[ "$tracking" ] || \
@@ -61,6 +62,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/heads/$tracking)

```

## Martin Schlemmer, 2005-04-14 23:04

Subject: Re: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <1113519890.23299.129.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113519890.23299.129.camel%40nosferatu.lan
In-Reply-To: <1113519445.23299.119.camel@nosferatu.lan>

```
On Fri, 2005-04-15 at 00:57 +0200, Martin Schlemmer wrote:
> Hi,
> 
> gitcancel.sh do not handle mode changes:
> 
> ----
> $ chmod -x Makefile
> $ git cancel
> patch: **** Only garbage was found in the patch input.
> ----
> 
> Rather use checkout-cache to sync our tree, as should do the right thing
> instead of diffing (cancel imply just blow away everything).
> 
> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> 
> gittrack.sh:  03d6db1fb3a70605ef249c632c04e542457f0808
> --- 03d6db1fb3a70605ef249c632c04e542457f0808/gittrack.sh
> +++ uncommitted/gittrack.sh
> @@ -51,6 +51,7 @@
> 
>         read-tree $(tree-id "$name")
>         gitdiff.sh local "$name" | gitapply.sh
> +       update-cache --refresh
> 
>  else
>         [ "$tracking" ] || \
> @@ -61,6 +62,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/heads/$tracking)

Yes, I am an idiot, and its past 1am already here.

Rather use checkout-cache to sync our tree, as should do the right thing
instead of diffing (cancel imply just blow away everything).

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

gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
--- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.

-# FIXME: Does not revert mode changes!

-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a

 update-cache --refresh


-- 
Martin Schlemmer



gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
--- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
+++ uncommitted/gitcancel.sh
@@ -10,9 +10,8 @@
 #
 # Takes no arguments. Takes the evil changes from the tree.
 
-# FIXME: Does not revert mode changes!
 
-show-diff | patch -p0 -R
 rm -f .git/add-queue .git/rm-queue
+checkout-cache -q -f -a
 
 update-cache --refresh

```

## Petr Baudis, 2005-04-14 23:07

Subject: Re: Re: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <20050414230712.GT22699@pasky.ji.cz>
URL: https://gitlist.dev/e/20050414230712.GT22699%40pasky.ji.cz
In-Reply-To: <1113519890.23299.129.camel@nosferatu.lan>

```
Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Rather use checkout-cache to sync our tree, as should do the right thing
> instead of diffing (cancel imply just blow away everything).
> 
> Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> 
> gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
> --- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
> +++ uncommitted/gitcancel.sh
> @@ -10,9 +10,8 @@
>  #
>  # Takes no arguments. Takes the evil changes from the tree.
> 
> -# FIXME: Does not revert mode changes!
> 
> -show-diff | patch -p0 -R
>  rm -f .git/add-queue .git/rm-queue
> +checkout-cache -q -f -a
> 
>  update-cache --refresh

Why -q?

Never make things silent unless you really know what are you doing and
why. The same goes for popular throwing of -f to rm's of files which
should always exist or 2>/dev/null for cats.

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

```

## Martin Schlemmer, 2005-04-14 23:14

Subject: Re: Re: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <1113520447.23299.137.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113520447.23299.137.camel%40nosferatu.lan
In-Reply-To: <20050414230712.GT22699@pasky.ji.cz>

```
On Fri, 2005-04-15 at 01:07 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Rather use checkout-cache to sync our tree, as should do the right thing
> > instead of diffing (cancel imply just blow away everything).
> > 
> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > 
> > gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
> > --- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
> > +++ uncommitted/gitcancel.sh
> > @@ -10,9 +10,8 @@
> >  #
> >  # Takes no arguments. Takes the evil changes from the tree.
> > 
> > -# FIXME: Does not revert mode changes!
> > 
> > -show-diff | patch -p0 -R
> >  rm -f .git/add-queue .git/rm-queue
> > +checkout-cache -q -f -a
> > 
> >  update-cache --refresh
> 
> Why -q?
> 
> Never make things silent unless you really know what are you doing and
> why. The same goes for popular throwing of -f to rm's of files which
> should always exist or 2>/dev/null for cats.
> 

Uhm, no particular reason (other than perhaps working usually on stuff
where too much info just confuses the user).  If its fine in spirit, the
-q can go.


-- 
Martin Schlemmer


```

## Martin Schlemmer, 2005-04-14 23:39

Subject: Re: Re: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <1113521946.23299.143.camel@nosferatu.lan>
URL: https://gitlist.dev/e/1113521946.23299.143.camel%40nosferatu.lan
In-Reply-To: <20050414231558.GW22699@pasky.ji.cz>

```
On Fri, 2005-04-15 at 01:15 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Rather use checkout-cache to sync our tree, as should do the right thing
> > instead of diffing (cancel imply just blow away everything).
> > 
> > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > 
> > gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
> > --- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
> > +++ uncommitted/gitcancel.sh
> > @@ -10,9 +10,8 @@
> >  #
> >  # Takes no arguments. Takes the evil changes from the tree.
> > 
> > -# FIXME: Does not revert mode changes!
> > 
> > -show-diff | patch -p0 -R
> >  rm -f .git/add-queue .git/rm-queue
> > +checkout-cache -q -f -a
> > 
> >  update-cache --refresh
> 

PS, shouldn't we add a read-tree $(tree-id) before the checkout-cache?


-- 
Martin Schlemmer


```

## Petr Baudis, 2005-04-14 23:49

Subject: Re: Re: Re: [patch pasky] update gitcancel.sh to handle modes as well
Message-ID: <20050414234901.GY22699@pasky.ji.cz>
URL: https://gitlist.dev/e/20050414234901.GY22699%40pasky.ji.cz
In-Reply-To: <1113521946.23299.143.camel@nosferatu.lan>

```
Dear diary, on Fri, Apr 15, 2005 at 01:39:06AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> On Fri, 2005-04-15 at 01:15 +0200, Petr Baudis wrote:
> > Dear diary, on Fri, Apr 15, 2005 at 01:04:50AM CEST, I got a letter
> > where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > > Rather use checkout-cache to sync our tree, as should do the right thing
> > > instead of diffing (cancel imply just blow away everything).
> > > 
> > > Signed-off-by: Martin Schlemmer <azarah@nosferatu.za.org>
> > > 
> > > gitcancel.sh:  839b3c58f20f6eb8412f499a891e007e2e67d114
> > > --- 839b3c58f20f6eb8412f499a891e007e2e67d114/gitcancel.sh
> > > +++ uncommitted/gitcancel.sh
> > > @@ -10,9 +10,8 @@
> > >  #
> > >  # Takes no arguments. Takes the evil changes from the tree.
> > > 
> > > -# FIXME: Does not revert mode changes!
> > > 
> > > -show-diff | patch -p0 -R
> > >  rm -f .git/add-queue .git/rm-queue
> > > +checkout-cache -q -f -a
> > > 
> > >  update-cache --refresh
> > 
> 
> PS, shouldn't we add a read-tree $(tree-id) before the checkout-cache?

A correct tree should be in the index. And if for any completely weird
and smelly reason it isn't, I'm pondering if we should back that out and
always reread-tree (takes some time, but do you do git cancel all the
time?), or rather comply to it and adjust to the loaded tree, whichever
it is.

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

```
