Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d0d33d32b | |||
| b2fd270558 | |||
| 3d7177e84c | |||
| 8bbe2a7d49 | |||
| 136a777d73 |
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2019 Ivan Malopinsky
|
||||
Copyright (c) 2017-2020 Ivan Malopinsky
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -159,7 +159,14 @@ fi
|
||||
ERR="could not get top-level-directory"
|
||||
TOP_LEVEL_DIRECTORY=$(git rev-parse --show-toplevel)
|
||||
REMOTE=${1:-origin}
|
||||
ROOT=${2:-master}
|
||||
|
||||
ROOT_GUESS=master
|
||||
|
||||
if [[ -n $(git show-ref refs/heads/main) && -z $(git show-ref refs/heads/master) ]]; then
|
||||
ROOT_GUESS=main
|
||||
fi
|
||||
|
||||
ROOT=${2:-$ROOT_GUESS}
|
||||
|
||||
# Recover the root HEAD if it is missing or corrupt (e.g. master head reads "master")
|
||||
recover_root () {
|
||||
@@ -185,6 +192,9 @@ recover_root () {
|
||||
|
||||
recover_root
|
||||
|
||||
LAST_WORKING_DIRECTORY="$(pwd)"
|
||||
cd "$TOP_LEVEL_DIRECTORY"
|
||||
|
||||
ERR="could not get current commit"
|
||||
CURRENT=$(git rev-parse --abbrev-ref HEAD)
|
||||
ERR=""
|
||||
@@ -378,6 +388,12 @@ if ! git gc --auto --force; then
|
||||
rm -rf "$TOP_LEVEL_DIRECTORY/.git/gc.log"
|
||||
fi
|
||||
|
||||
if [[ -d "$LAST_WORKING_DIRECTORY" ]]; then
|
||||
cd "$LAST_WORKING_DIRECTORY"
|
||||
else
|
||||
say "Previous working directory does not exist on the branch $ROOT"
|
||||
fi
|
||||
|
||||
recover_root
|
||||
|
||||
ERR=""
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "git-fresh",
|
||||
"version": "1.12.1",
|
||||
"version": "1.13.0",
|
||||
"description": "Utility to keep Git repositories fresh",
|
||||
"global": true,
|
||||
"repo": "imsky/git-fresh",
|
||||
|
||||
Reference in New Issue
Block a user