[sysadmin-bin] run-git-or-special-cmd: Fix handling of .git suffix
- From: Owen Taylor <otaylor src gnome org>
- To: gnome-sysadmin gnome org,commits-list gnome org
- Subject: [sysadmin-bin] run-git-or-special-cmd: Fix handling of .git suffix
- Date: Fri, 6 Sep 2013 16:38:58 +0000 (UTC)
commit 4cbb4fa6ae4f83d92b13a8e00f280f371ef05e2b
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Fri Sep 6 12:38:12 2013 -0400
run-git-or-special-cmd: Fix handling of .git suffix
run-git-or-special-cmd | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/run-git-or-special-cmd b/run-git-or-special-cmd
index 460a599..3db2d05 100755
--- a/run-git-or-special-cmd
+++ b/run-git-or-special-cmd
@@ -27,10 +27,14 @@ is_sysadmin = sysadmin_gid in groups
# os.path.normpath can't be used for security because it's
# only textual and doesn't check symlinks.
# /home/joe.smith/foo/../../../git isn't necessarily /git
-def normalize_path(path):
+def find_and_normalize_git_dir(path):
curpath = os.getcwd()
try:
- os.chdir(path)
+ try:
+ os.chdir(path)
+ except OSError:
+ path += ".git"
+ os.chdir(path)
return os.getcwd()
except:
return None
@@ -38,7 +42,7 @@ def normalize_path(path):
os.chdir(curpath)
def validate_git_dir(path):
- path = normalize_path(path)
+ path = find_and_normalize_git_dir(path)
if path is None:
print >>sys.stderr, "git repository does not exist."
sys.exit(1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]