{"thread":{"id":"1456","subject":"A simple script to do the reverse of git-push","startedAt":"2005-08-08T21:25:49Z","lastAt":"2005-08-11T22:18:12Z","messageCount":4,"participants":["Johannes Schindelin","Junio C Hamano","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"6953","messageId":"Pine.LNX.4.63.0508082318400.2911@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1456","inReplyTo":null,"subject":"A simple script to do the reverse of git-push","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-08T21:25:49Z","receivedAt":"2005-08-08T21:25:49Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi list,\n\nI mentioned in another mail that I needed the opposite of git-push, namely \ngetting all heads, and if they are strict parents of the local refs, just \nupdate them.\n\nWell, Junio pointed out that it's easy using the available tools, and he \nwas right. The result is attached (and tested...).\n\nThis script makes it easy to work with a central repository, multiple \nheads and users, in a CVS style: to start your day, you call the attached \nscript, and after you have committed something, you can do a push on the \nrepository. Sometimes, the push fails, then you have to pull that branch \nin order to merge it before trying a push again.\n\nBTW, if you are lazy, like me, you just pull from Junio once in a while \nand do a \"make test\". Turns out there is a missing dependency though:\n\npeek-remote.o: cache.h\n\nwhich in my case lead to a git-peek-remote program which was unable to \npeek any ref.\n\nCiao,\nDscho\n\n\n#!/bin/sh\n\n. git-sh-setup-script || die \"Not a git archive\"\n\n. git-parse-remote \"$@\"\nrepo=\"$_remote_repo\"\n\ngit-ls-remote-script --heads \"$repo\" | while read sha1 refname; do\n\tshortname=$(basename $refname)\n\tif [ -e $GIT_DIR/$refname ]; then\n\t\tif [ $sha1 = $(cat $GIT_DIR/$refname) ]; then\n\t\t\techo $shortname up to date. 1>&2\n\t\t\tcontinue\n\t\tfi\n\tfi\n\n\tgit-cat-file commit $sha1 >/dev/null 2>&1 ||\n\tgit-fetch-script $repo $shortname\n\n\tif [ ! -e $GIT_DIR/$refname ]; then\n\t\techo Got new head $shortname 1>&2\n\t\techo $sha1 > $GIT_DIR/$refname\n\telse\n\t\torigsha1=$(cat $GIT_DIR/$refname)\n\t\tif [ -z \"$(git-rev-list $origsha1 ^$sha1)\" ]; then\n\t\t\techo Updated head $shortname 1>&2\n\t\t\techo $sha1 > $GIT_DIR/$refname\n\t\telse\n\t\t\tsaveref=$GIT_DIR/FETCH_HEAD_$shortname\n\t\t\techo Error: $shortname not a child of remote head 1>&2\n\t\t\techo \"\tSaved remote head to $saveref\" 1>&2\n\t\t\techo $sha1 > $saveref\n\t\tfi\n\tfi\ndone\n\n"},{"id":"6960","messageId":"7vslxk125f.fsf@assigned-by-dhcp.cox.net","threadId":"1456","inReplyTo":"Pine.LNX.4.63.0508082318400.2911@wgmdd8.biozentrum.uni-wuerzburg.de","subject":"Re: A simple script to do the reverse of git-push","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-08T22:42:36Z","receivedAt":"2005-08-08T22:42:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> BTW, if you are lazy, like me, you just pull from Junio once in a while \n> and do a \"make test\". Turns out there is a missing dependency though:\n>\n> peek-remote.o: cache.h\n>\n> which in my case lead to a git-peek-remote program which was unable to \n> peek any ref.\n\nYou are right.  Thanks for noticing.\n\n    $ (make clean ; make ) >/dev/null 2>/dev/null\n    $ touch cache.h\n    $ make 2>&1 | grep peek-remote\n    cc -g -O2 -Wall  '-DSHA1_HEADER=<openssl/sha.h>' -o git-peek-remote peek-remote.o libgit.a -lz -lcrypto\n\nI think recent \"depend on object files\" Makefile patch broke\nsome things.\n\nWe would need something like this.\n---\n# - pu: ls-remote: drop storing operation and add documentation.\n# + (working tree)\ndiff --git a/Makefile b/Makefile\n--- a/Makefile\n+++ b/Makefile\n@@ -172,6 +172,7 @@ init-db.o: init-db.c\n \t$(CC) -c $(CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='\"$(template_dir)\"' $*.c\n \n $(LIB_OBJS): $(LIB_H)\n+$(patsubst git-%,%.o,$(PROG)): $(LIB_H)\n $(DIFF_OBJS): diffcore.h\n \n $(LIB_FILE): $(LIB_OBJS)\n"},{"id":"6965","messageId":"Pine.LNX.4.63.0508090135230.3695@wgmdd8.biozentrum.uni-wuerzburg.de","threadId":"1456","inReplyTo":"7vslxk125f.fsf@assigned-by-dhcp.cox.net","subject":"Re: A simple script to do the reverse of git-push","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-08-08T23:38:46Z","receivedAt":"2005-08-08T23:38:46Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 8 Aug 2005, Junio C Hamano wrote:\n\n> We would need something like this.\n>\n> [...]\n>\n> +$(patsubst git-%,%.o,$(PROG)): $(LIB_H)\n\nA short\n\n\tfor i in git-*; do \\\n\t\tc=$(echo $i|sed \"s/git-\\(.*\\)/\\1.c/g\")\n\t\tif [ -e $c ]; then \\\n\t\t\tif ! grep cache\\\\.h $c; then \\\n\t\t\t\techo $c does not depend on cache.h \\\n\t\t\tfi \\\n\t\tfi \\\n\tdone\n\n(actually tested) reveals that only get-tar-commit-id.c and stripspace.c \ndo not depend on cache.h or rev-cache.h. Thus, your patch is the most \nelegant solution to my problem :-)\n\nCiao,\nDscho\n"},{"id":"7082","messageId":"20050811221812.GG25280@pasky.ji.cz","threadId":"1456","inReplyTo":"7vslxk125f.fsf@assigned-by-dhcp.cox.net","subject":"Re: A simple script to do the reverse of git-push","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2005-08-11T22:18:12Z","receivedAt":"2005-08-11T22:18:12Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Tue, Aug 09, 2005 at 12:42:36AM CEST, I got a letter\nwhere Junio C Hamano <junkio@cox.net> told me that...\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > BTW, if you are lazy, like me, you just pull from Junio once in a while \n> > and do a \"make test\". Turns out there is a missing dependency though:\n> >\n> > peek-remote.o: cache.h\n> >\n> > which in my case lead to a git-peek-remote program which was unable to \n> > peek any ref.\n> \n> You are right.  Thanks for noticing.\n> \n>     $ (make clean ; make ) >/dev/null 2>/dev/null\n>     $ touch cache.h\n>     $ make 2>&1 | grep peek-remote\n>     cc -g -O2 -Wall  '-DSHA1_HEADER=<openssl/sha.h>' -o git-peek-remote peek-remote.o libgit.a -lz -lcrypto\n> \n> I think recent \"depend on object files\" Makefile patch broke\n> some things.\n\nIndeed. I took care to make the new dependencies a superset of previous\nsituation when removing the explicit dependencies list, but before,\nrebuilding of libgit.a caused rebuilt from source of all the commands,\nwhich wouldn't happen anymore after adding the object files, which this\nway sneakily removed an implicit dependency of the command sources on\n$(LIB_H). Eek.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nIf you want the holes in your knowledge showing up try teaching\nsomeone.  -- Alan Cox\n"}]}