From 24b6177e0261efba063c0b83ae0cdc5993945da9 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Sun, 13 Apr 2008 11:56:54 +0200 Subject: git-remote: reject adding remotes with invalid names This can happen if the arguments to git-remote add is switched by the user, and git would only show an error if fetching was also requested. Fix it by using the refspec parsing engine to check if the requested name can be parsed as a remote before add it. Also cleanup so that the "remote..url" config name buffer is only initialized once. Signed-off-by: Jonas Fonseca Signed-off-by: Junio C Hamano --- t/t5505-remote.sh | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 't') diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index 0a7fea865..af2d07779 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -253,4 +253,10 @@ test_expect_success '"remote show" does not show symbolic refs' ' ' +test_expect_success 'reject adding remote with an invalid name' ' + + ! git remote add some:url desired-name + +' + test_done -- cgit v1.2.1 From 5634cf24766f8700804ca55f5e8567c88538a5b0 Mon Sep 17 00:00:00 2001 From: Jakub Narebski Date: Sun, 13 Apr 2008 14:12:15 +0200 Subject: gitweb: Fix 'history' view for deleted files with history When asked for history of a file which is not present in given branch ("HEAD", i.e. current branch, or given by transient $hash_hase ('hb') parameter), but is present deeper in the history (meaning that "git rev-list --full-history $hash_base -- $file_name" is not empty), and there is no $hash ('h') parameter set for a file, gitweb would spew multiple of "Use of uninitialized value" warnings, and some links would be missing. This commit fixes this bug. This bug occurs in the rare cases when "git log -- " is empty and "git log --full-history -- " is not, or to be more exact in the cases when full-history starts later than given branch. It can happen if you are using handcrafted gitwb URL, or if you follow generic 'history' link or bookmark for a file which got deleted. Gitweb tried to get file type ('tree', or 'blob', or even 'commit') from the commit we start searching from (where the file was not present), and not among found commits. This was the cause of "Use of uninitialized value" warnings. This commit also add tests for such situation to t9500 test. While we are it, return HTTP error if there is _no_ history; it means that file or directory was not found (for given branch). Also error out if type of item could not be found: it should not happen now, but better be sure. Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- t/t9500-gitweb-standalone-no-errors.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't') diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh index 796cd7dba..061a2596d 100755 --- a/t/t9500-gitweb-standalone-no-errors.sh +++ b/t/t9500-gitweb-standalone-no-errors.sh @@ -483,6 +483,22 @@ test_expect_success \ 'gitweb_run "p=.git;a=history;f=file"' test_debug 'cat gitweb.log' +test_expect_success \ + 'logs: history (implicit HEAD, non-existent file)' \ + 'gitweb_run "p=.git;a=history;f=non-existent"' +test_debug 'cat gitweb.log' + +test_expect_success \ + 'logs: history (implicit HEAD, deleted file)' \ + 'git checkout master && + echo "to be deleted" > deleted_file && + git add deleted_file && + git commit -m "Add file to be deleted" && + git rm deleted_file && + git commit -m "Delete file" && + gitweb_run "p=.git;a=history;f=deleted_file"' +test_debug 'cat gitweb.log' + # ---------------------------------------------------------------------- # feed generation -- cgit v1.2.1