* [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all)
@ 2005-04-15 9:28 Martin Schlemmer
2005-04-15 9:31 ` Martin Schlemmer
2005-04-15 18:15 ` Petr Baudis
0 siblings, 2 replies; 4+ messages in thread
From: Martin Schlemmer @ 2005-04-15 9:28 UTC (permalink / raw)
To: GIT Mailing Lists; +Cc: Petr Baudis
[-- Attachment #1.1: Type: text/plain, Size: 2904 bytes --]
Hi,
The egrep regex should not escape the '{' and '}', and also add a check
for ' \t' so that we do not pickup stuff like '+----', etc. Fix typo in
assignment. Check if file exists in new tree before adding/removing
(might add support for this lowlevel to increase speed?). Fix typo in
line removing temp files.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
gitapply.sh: 47b9346d2679b1bf34220fe4502f15c7d0737b0c
--- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh
+++ uncommitted/gitapply.sh
@@ -19,15 +19,22 @@
# just handle it all ourselves.
patch -p1 -N <$patchfifo &
-tee $patchfifo | egrep '^[+-]\{3\}' | {
+exits_in_cache() {
+ for x in $(ls-tree "$1"); do
+ [ "$x" = "$2" ] && return 0
+ done
+ return 1
+}
+
+tee $patchfifo | egrep '^[+-]{3}[ \t]' | {
victim=
origmode=
while read sign file attrs; do
- echo $sign $file $attrs ... >&2
+# echo $sign $file $attrs ... >&2
case $sign in
"---")
- victim=file
+ victim=$file
mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
origmode=
[ "$mode" != "$attrs" ] && origmode=$mode
@@ -35,14 +42,19 @@
"+++")
if [ "$file" = "/dev/null" ]; then
torm=$(echo "$victim" | sed 's/[^\/]*\///') #-p1
- echo -ne "rm\0$torm\0"
+ tree=$(echo $attrs | sed 's/.*tree:\([0-9a-f]\{40\}\).*/\1/')
+ exits_in_cache "$tree" "$torm" && echo -ne "rm\0$torm\0"
continue
elif [ "$victim" = "/dev/null" ]; then
- echo -ne "add\0$file\0"
+ toadd=$(echo "$file" | sed 's/[^\/]*\///') #-p1
+ tree=$(echo "$file" | sed -e 's/\([^\/]*\)\/.*/\1/')
+ exits_in_cache "$tree" "$toadd" || echo -ne "add\0$toadd\0"
fi
mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
if [ "$mode" ] && [ "$mode" != "$attrs" ] && [ "$origmode" != "$mode" ]; then
- echo -ne "cm\0$mode\0$file\0"
+ tochmod=$(echo "$file" | sed 's/[^\/]*\///') #-p1
+ # need a space else numbers gets converted
+ echo -ne "cm\0 $mode\0$tochmod\0"
fi
;;
*)
@@ -74,4 +86,4 @@
done
' padding
-rm $pathfifo $todo $gonefile
+rm $patchfifo $todo $gonefile
--
Martin Schlemmer
[-- Attachment #1.2: git-gitapply-fixes.patch --]
[-- Type: text/x-patch, Size: 1781 bytes --]
gitapply.sh: 47b9346d2679b1bf34220fe4502f15c7d0737b0c
--- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh
+++ uncommitted/gitapply.sh
@@ -19,15 +19,22 @@
# just handle it all ourselves.
patch -p1 -N <$patchfifo &
-tee $patchfifo | egrep '^[+-]\{3\}' | {
+exits_in_cache() {
+ for x in $(ls-tree "$1"); do
+ [ "$x" = "$2" ] && return 0
+ done
+ return 1
+}
+
+tee $patchfifo | egrep '^[+-]{3}[ \t]' | {
victim=
origmode=
while read sign file attrs; do
- echo $sign $file $attrs ... >&2
+# echo $sign $file $attrs ... >&2
case $sign in
"---")
- victim=file
+ victim=$file
mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
origmode=
[ "$mode" != "$attrs" ] && origmode=$mode
@@ -35,14 +42,19 @@
"+++")
if [ "$file" = "/dev/null" ]; then
torm=$(echo "$victim" | sed 's/[^\/]*\///') #-p1
- echo -ne "rm\0$torm\0"
+ tree=$(echo $attrs | sed 's/.*tree:\([0-9a-f]\{40\}\).*/\1/')
+ exits_in_cache "$tree" "$torm" && echo -ne "rm\0$torm\0"
continue
elif [ "$victim" = "/dev/null" ]; then
- echo -ne "add\0$file\0"
+ toadd=$(echo "$file" | sed 's/[^\/]*\///') #-p1
+ tree=$(echo "$file" | sed -e 's/\([^\/]*\)\/.*/\1/')
+ exits_in_cache "$tree" "$toadd" || echo -ne "add\0$toadd\0"
fi
mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
if [ "$mode" ] && [ "$mode" != "$attrs" ] && [ "$origmode" != "$mode" ]; then
- echo -ne "cm\0$mode\0$file\0"
+ tochmod=$(echo "$file" | sed 's/[^\/]*\///') #-p1
+ # need a space else numbers gets converted
+ echo -ne "cm\0 $mode\0$tochmod\0"
fi
;;
*)
@@ -74,4 +86,4 @@
done
' padding
-rm $pathfifo $todo $gonefile
+rm $patchfifo $todo $gonefile
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all)
2005-04-15 9:28 [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all) Martin Schlemmer
@ 2005-04-15 9:31 ` Martin Schlemmer
2005-04-15 18:15 ` Petr Baudis
1 sibling, 0 replies; 4+ messages in thread
From: Martin Schlemmer @ 2005-04-15 9:31 UTC (permalink / raw)
To: GIT Mailing Lists; +Cc: Petr Baudis
[-- Attachment #1: Type: text/plain, Size: 3270 bytes --]
PS: forget the '1/2' in the topic, i did it slightly different which
required changes to gettrack.sh, etc, but to got getmerge.sh, and saw my
short sightedness.
On Fri, 2005-04-15 at 11:28 +0200, Martin Schlemmer wrote:
> Hi,
>
> The egrep regex should not escape the '{' and '}', and also add a check
> for ' \t' so that we do not pickup stuff like '+----', etc. Fix typo in
> assignment. Check if file exists in new tree before adding/removing
> (might add support for this lowlevel to increase speed?). Fix typo in
> line removing temp files.
>
> Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
>
> gitapply.sh: 47b9346d2679b1bf34220fe4502f15c7d0737b0c
> --- 47b9346d2679b1bf34220fe4502f15c7d0737b0c/gitapply.sh
> +++ uncommitted/gitapply.sh
> @@ -19,15 +19,22 @@
> # just handle it all ourselves.
> patch -p1 -N <$patchfifo &
>
> -tee $patchfifo | egrep '^[+-]\{3\}' | {
> +exits_in_cache() {
> + for x in $(ls-tree "$1"); do
> + [ "$x" = "$2" ] && return 0
> + done
> + return 1
> +}
> +
> +tee $patchfifo | egrep '^[+-]{3}[ \t]' | {
> victim=
> origmode=
>
> while read sign file attrs; do
> - echo $sign $file $attrs ... >&2
> +# echo $sign $file $attrs ... >&2
> case $sign in
> "---")
> - victim=file
> + victim=$file
> mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
> origmode=
> [ "$mode" != "$attrs" ] && origmode=$mode
> @@ -35,14 +42,19 @@
> "+++")
> if [ "$file" = "/dev/null" ]; then
> torm=$(echo "$victim" | sed 's/[^\/]*\///') #-p1
> - echo -ne "rm\0$torm\0"
> + tree=$(echo $attrs | sed 's/.*tree:\([0-9a-f]\{40\}\).*/\1/')
> + exits_in_cache "$tree" "$torm" && echo -ne "rm\0$torm\0"
> continue
> elif [ "$victim" = "/dev/null" ]; then
> - echo -ne "add\0$file\0"
> + toadd=$(echo "$file" | sed 's/[^\/]*\///') #-p1
> + tree=$(echo "$file" | sed -e 's/\([^\/]*\)\/.*/\1/')
> + exits_in_cache "$tree" "$toadd" || echo -ne "add\0$toadd\0"
> fi
> mode=$(echo $attrs | sed 's/.*mode:[0-7]*\([0-7]\{3\}\).*/\1/')
> if [ "$mode" ] && [ "$mode" != "$attrs" ] && [ "$origmode" != "$mode" ]; then
> - echo -ne "cm\0$mode\0$file\0"
> + tochmod=$(echo "$file" | sed 's/[^\/]*\///') #-p1
> + # need a space else numbers gets converted
> + echo -ne "cm\0 $mode\0$tochmod\0"
> fi
> ;;
> *)
> @@ -74,4 +86,4 @@
> done
> ' padding
>
> -rm $pathfifo $todo $gonefile
> +rm $patchfifo $todo $gonefile
>
>
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: fix various issues in gitapply.sh (basically did not handle add/del/cm at all)
2005-04-15 9:28 [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all) Martin Schlemmer
2005-04-15 9:31 ` Martin Schlemmer
@ 2005-04-15 18:15 ` Petr Baudis
2005-04-15 20:30 ` Martin Schlemmer
1 sibling, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2005-04-15 18:15 UTC (permalink / raw)
To: Martin Schlemmer; +Cc: GIT Mailing Lists
Dear diary, on Fri, Apr 15, 2005 at 11:28:38AM CEST, I got a letter
where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> Hi,
>
> The egrep regex should not escape the '{' and '}', and also add a check
> for ' \t' so that we do not pickup stuff like '+----', etc. Fix typo in
> assignment. Check if file exists in new tree before adding/removing
> (might add support for this lowlevel to increase speed?). Fix typo in
> line removing temp files.
>
> Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Thanks for the merge and typo fixes. I can't imagine how, but it really
appeared to work for me that time!
I'm confused however what does the exits_in_cache() (what exits? exists?)
gives us, apart of horribly-looking code. What bug does it fix?
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] 4+ messages in thread* Re: fix various issues in gitapply.sh (basically did not handle add/del/cm at all)
2005-04-15 18:15 ` Petr Baudis
@ 2005-04-15 20:30 ` Martin Schlemmer
0 siblings, 0 replies; 4+ messages in thread
From: Martin Schlemmer @ 2005-04-15 20:30 UTC (permalink / raw)
To: Petr Baudis; +Cc: GIT Mailing Lists
[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]
On Fri, 2005-04-15 at 20:15 +0200, Petr Baudis wrote:
> Dear diary, on Fri, Apr 15, 2005 at 11:28:38AM CEST, I got a letter
> where Martin Schlemmer <azarah@nosferatu.za.org> told me that...
> > Hi,
> >
> > The egrep regex should not escape the '{' and '}', and also add a check
> > for ' \t' so that we do not pickup stuff like '+----', etc. Fix typo in
> > assignment. Check if file exists in new tree before adding/removing
> > (might add support for this lowlevel to increase speed?). Fix typo in
> > line removing temp files.
> >
> > Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
>
> Thanks for the merge and typo fixes. I can't imagine how, but it really
> appeared to work for me that time!
>
> I'm confused however what does the exits_in_cache() (what exits? exists?)
> gives us, apart of horribly-looking code. What bug does it fix?
>
My typo it seems - should be exists. Basically (especially for
gittrack.sh) it will add all files changed between the trees to either
the add or remove queue if this is not done. This is because it will
just add (say git track linus; git track pasky) the git*.sh files that
is missing in the linus tree (or gitrm.sh if in reverse) although they
are already present there. So we need to check if the file exists in
the destination tree before we git{add,rm}.sh it - if it do exists, then
its ok to gitrm.sh it, if it does not, it is ok to gitadd.sh it.
The other problem is also that if you keep switching, it will add each
file multiple times to the add/rm queue. This is a bug with
git{add,rm}.sh which do not check the queue if the file is already
there, and it also add a file even if it is already in the cache - so it
probably need the same type of fix. I will send a patch when we get how
we check if a file is already in the cache resolved.
Like I said in the patch, it might be better to add support low-level
side (don't know if we can have ls-tree return true/false on file basis,
else add a new tool?).
Thanks,
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-04-15 20:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-15 9:28 [patch pasky 1/2] fix various issues in gitapply.sh (basically did not handle add/del/cm at all) Martin Schlemmer
2005-04-15 9:31 ` Martin Schlemmer
2005-04-15 18:15 ` Petr Baudis
2005-04-15 20:30 ` Martin Schlemmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox