From affa40d2f8c5e72af5896cf395ef77d4162908cd Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Mon, 8 Aug 2005 10:53:23 +0100 Subject: [PATCH] Make curl fail on server error Some http servers return an HTML error page and git reads it as normal data. Adding -f option makes curl fail silently. Signed-off-by: Catalin Marinas Signed-off-by: Junio C Hamano diff --git a/git-clone-dumb-http b/git-clone-dumb-http index 8203c67..5052708 100755 --- a/git-clone-dumb-http +++ b/git-clone-dumb-http @@ -14,7 +14,7 @@ if [ -n "$GIT_SSL_NO_VERIFY" ]; then fi http_fetch () { # $1 = Remote, $2 = Local - curl -ns $curl_extra_args "$1" >"$2" + curl -nsf $curl_extra_args "$1" >"$2" } cd "$D" && diff --git a/git-fetch-script b/git-fetch-script index a0326f0..24f0a5e 100755 --- a/git-fetch-script +++ b/git-fetch-script @@ -15,7 +15,7 @@ http://* | https://*) fi _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' && _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" && - head=$(curl -ns $curl_extra_args "$merge_repo/$merge_head") && + head=$(curl -nsf $curl_extra_args "$merge_repo/$merge_head") && expr "$head" : "$_x40\$" >/dev/null || { echo >&2 "Failed to fetch $merge_head from $merge_repo" exit 1 diff --git a/git-ls-remote-script b/git-ls-remote-script index 921d3f8..31cdac8 100755 --- a/git-ls-remote-script +++ b/git-ls-remote-script @@ -46,7 +46,7 @@ http://* | https://* ) if [ -n "$GIT_SSL_NO_VERIFY" ]; then curl_extra_args="-k" fi - curl -ns $curl_extra_args "$peek_repo/info/refs" || exit 1 + curl -nsf $curl_extra_args "$peek_repo/info/refs" || exit 1 ;; rsync://* ) -- cgit v0.10.2-6-g49f6 From 35c3c6298308563a3dd4a5c4bb0870748833643f Mon Sep 17 00:00:00 2001 From: Holger Eitzenberger Date: Mon, 8 Aug 2005 22:33:08 +0200 Subject: [PATCH] git_mkstemp() fix git_mkstemp() attempted to use TMPDIR environment variable, but it botched copying the templates. [jc: Holger, please add your own Signed-off-by line, and also if you can, send in future patches as non attachments.] Signed-off-by: Junio C Hamano diff --git a/path.c b/path.c index 7ef0d1b..b85f087 100644 --- a/path.c +++ b/path.c @@ -68,8 +68,13 @@ int git_mkstemp(char *path, size_t len, const char *template) if ((env = getenv("TMPDIR")) == NULL) { strcpy(pch, "/tmp/"); len -= 5; - } else - len -= snprintf(pch, len, "%s/", env); + pch += 5; + } else { + size_t n = snprintf(pch, len, "%s/", env); + + len -= n; + pch += n; + } safe_strncpy(pch, template, len); -- cgit v0.10.2-6-g49f6 From 1cf58e72225f45472124266c020f8595988374d8 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 8 Aug 2005 22:44:43 +0400 Subject: [PATCH] Plug memory leak in read_object_with_reference() When following a reference, read_object_with_reference() did not free the intermediate object data. Signed-off-by: Sergey Vlasov Signed-off-by: Junio C Hamano diff --git a/sha1_file.c b/sha1_file.c index a17a6d1..a4bf067 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1165,6 +1165,7 @@ void *read_object_with_reference(const unsigned char *sha1, free(buffer); return NULL; } + free(buffer); /* Now we have the ID of the referred-to object in * actual_sha1. Check again. */ } -- cgit v0.10.2-6-g49f6 From bfc66daf5c0dcb1a507ff2533760ac5505eee6a3 Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 8 Aug 2005 22:45:36 +0400 Subject: [PATCH] Plug memory leak in write_sha1_to_fd() If the object to write was packed, both its uncompressed and compressed data were leaked. If the object was not packed, its file was not unmapped. [jc: I think it still leaks on the write error path of write_sha1_to_fd(), but that should be fixable in a small separate patch.] Signed-off-by: Sergey Vlasov Signed-off-by: Junio C Hamano diff --git a/sha1_file.c b/sha1_file.c index a4bf067..e9285c1 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1297,8 +1297,11 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) ssize_t size; unsigned long objsize; int posn = 0; - void *buf = map_sha1_file_internal(sha1, &objsize); + void *map = map_sha1_file_internal(sha1, &objsize); + void *buf = map; + void *temp_obj = NULL; z_stream stream; + if (!buf) { unsigned char *unpacked; unsigned long len; @@ -1314,7 +1317,7 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) memset(&stream, 0, sizeof(stream)); deflateInit(&stream, Z_BEST_COMPRESSION); size = deflateBound(&stream, len + hdrlen); - buf = xmalloc(size); + temp_obj = buf = xmalloc(size); /* Compress it */ stream.next_out = buf; @@ -1332,6 +1335,7 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) while (deflate(&stream, Z_FINISH) == Z_OK) /* nothing */; deflateEnd(&stream); + free(unpacked); objsize = stream.total_out; } @@ -1348,6 +1352,12 @@ int write_sha1_to_fd(int fd, const unsigned char *sha1) } posn += size; } while (posn < objsize); + + if (map) + munmap(map, objsize); + if (temp_obj) + free(temp_obj); + return 0; } -- cgit v0.10.2-6-g49f6 From 7bf058f0082d17b25b343782e3a33779cc7c956d Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 8 Aug 2005 22:46:13 +0400 Subject: [PATCH] Plug memory leak in sha1close() sha1create() and sha1fd() malloc the returned struct sha1file; sha1close() should free it. Signed-off-by: Sergey Vlasov Signed-off-by: Junio C Hamano diff --git a/csum-file.c b/csum-file.c index 907efbf..c66b9eb 100644 --- a/csum-file.c +++ b/csum-file.c @@ -45,6 +45,7 @@ int sha1close(struct sha1file *f, unsigned char *result, int update) sha1flush(f, 20); if (close(f->fd)) die("%s: sha1 file error on close (%s)", f->name, strerror(errno)); + free(f); return 0; } -- cgit v0.10.2-6-g49f6 From adee7bdf504120055b0f36b4918bdd3e6156912b Mon Sep 17 00:00:00 2001 From: Sergey Vlasov Date: Mon, 8 Aug 2005 22:46:58 +0400 Subject: [PATCH] Plug memory leak in git-pack-objects find_deltas() should free its temporary objects before returning. [jc: Sergey, if you have [PATCH] title on the Subject line of your e-mail, please do not repeat it on the first line in your message body. Thanks.] Signed-off-by: Sergey Vlasov Signed-off-by: Junio C Hamano diff --git a/pack-objects.c b/pack-objects.c index ed24a33..3d62278 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -382,6 +382,10 @@ static void find_deltas(struct object_entry **list, int window, int depth) if (idx >= window) idx = 0; } + + for (i = 0; i < window; ++i) + free(array[i].data); + free(array); } int main(int argc, char **argv) -- cgit v0.10.2-6-g49f6 From c882bc932f6702a935c748893536356b0bba11ce Mon Sep 17 00:00:00 2001 From: Chris Wright Date: Mon, 8 Aug 2005 17:04:42 -0700 Subject: [PATCH] Add -m option to "git tag" Allow users to create a tag message by passing message on command line instead of requiring an $EDITOR session. Signed-off-by: Chris Wright Signed-off-by: Junio C Hamano diff --git a/git-tag-script b/git-tag-script index 4917f99..d3074a8 100755 --- a/git-tag-script +++ b/git-tag-script @@ -4,13 +4,14 @@ . git-sh-setup-script || die "Not a git archive" usage () { - echo >&2 "Usage: git-tag-script [-a | -s] [-f] tagname" + echo >&2 "Usage: git-tag-script [-a | -s] [-f] [-m "tag message"] tagname" exit 1 } annotate= signed= force= +message= while case "$#" in 0) break ;; esac do case "$1" in @@ -24,6 +25,11 @@ do -f) force=1 ;; + -m) + annotate=1 + shift + message="$1" + ;; -*) usage ;; @@ -48,10 +54,14 @@ tagger=$(git-var GIT_COMMITTER_IDENT) || exit 1 trap 'rm -f .tmp-tag* .tagmsg .editmsg' 0 if [ "$annotate" ]; then - ( echo "#" - echo "# Write a tag message" - echo "#" ) > .editmsg - ${VISUAL:-${EDITOR:-vi}} .editmsg || exit + if [ -z "$message" ]; then + ( echo "#" + echo "# Write a tag message" + echo "#" ) > .editmsg + ${VISUAL:-${EDITOR:-vi}} .editmsg || exit + else + echo "$message" > .editmsg + fi grep -v '^#' < .editmsg | git-stripspace > .tagmsg -- cgit v0.10.2-6-g49f6