From owner-svn-src-all@freebsd.org Fri Nov 11 23:07:32 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8174DC3915F; Fri, 11 Nov 2016 23:07:32 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4DFED1763; Fri, 11 Nov 2016 23:07:32 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uABN7VMb086636; Fri, 11 Nov 2016 23:07:31 GMT (envelope-from rstone@FreeBSD.org) Received: (from rstone@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uABN7V6U086633; Fri, 11 Nov 2016 23:07:31 GMT (envelope-from rstone@FreeBSD.org) Message-Id: <201611112307.uABN7V6U086633@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rstone set sender to rstone@FreeBSD.org using -f From: Ryan Stone Date: Fri, 11 Nov 2016 23:07:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r308562 - head/tools/tools/git X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Nov 2016 23:07:32 -0000 Author: rstone Date: Fri Nov 11 23:07:31 2016 New Revision: 308562 URL: https://svnweb.freebsd.org/changeset/base/308562 Log: Fix git tools when run against a worktree In a git worktree, the gitdir is in an entirely different location. In arcgit, use git rev-parse --git-dir to get the correct path to it always. When running git from outside of the work tree, as in importgit, the path provided by git rev-parse --git-dir can be either a relative or absolute path depending on the work tree. Rather than trying to deal with that, just use git -C. Differential Revision: https://reviews.freebsd.org/D8501 Reviewed by: markj Modified: head/tools/tools/git/arcgit head/tools/tools/git/importgit Modified: head/tools/tools/git/arcgit ============================================================================== --- head/tools/tools/git/arcgit Fri Nov 11 21:53:38 2016 (r308561) +++ head/tools/tools/git/arcgit Fri Nov 11 23:07:31 2016 (r308562) @@ -69,7 +69,7 @@ create_review() git checkout $commit > /dev/null || error "Could not checkout $commit" - arc_dir="$(git rev-parse --show-toplevel)/.git/arc" + arc_dir="$(git rev-parse --git-dir)/arc" arc_msg="$arc_dir/create-message" mkdir -p $arc_dir git show -s --format='%B' HEAD > $arc_msg Modified: head/tools/tools/git/importgit ============================================================================== --- head/tools/tools/git/importgit Fri Nov 11 21:53:38 2016 (r308561) +++ head/tools/tools/git/importgit Fri Nov 11 23:07:31 2016 (r308562) @@ -50,7 +50,7 @@ error() exit 1 } -unset git range commit dry_run +unset git_repo range commit dry_run while getopts ":c:g:nr:" o do @@ -95,16 +95,16 @@ then error -u "-g argument is mandatory" fi -git="$git_repo/.git" - -if [ ! -d "$git" ] +if ! type git > /dev/null 2> /dev/null then - error "$git_repo does not seem to be a git repo" + error "Install devel/git first" fi -if ! type git > /dev/null 2> /dev/null +GIT="git -C $git_repo" + +if ! $GIT rev-parse --git-dir 2> /dev/null > /dev/null then - error "Install devel/git first" + error "$git_repo does not seem to be a git repo" fi if ! type svn > /dev/null 2> /dev/null @@ -122,21 +122,21 @@ then error "Could not communicate with svn server. Is your ssh key loaded?" fi -git --git-dir=$git log --format=%H $range | tail -r | while read -r commit +$GIT log --format=%H $range | tail -r | while read -r commit do - echo "Applying `git --git-dir=$git show -s --oneline $commit`" + echo "Applying `$GIT show -s --oneline $commit`" - if [ -n "$(git --git-dir=$git show --diff-filter=CDRTUXB $commit)" ] + if [ -n "$($GIT show --diff-filter=CDRTUXB $commit)" ] then error "Commit performed unsupported change (e.g. delete/rename)" fi - if [ "$(git --git-dir=$git show -s --format=%P $commit | wc -w)" -ne 1 ] + if [ "$($GIT show -s --format=%P $commit | wc -w)" -ne 1 ] then error "Cannot import merge commits" fi - git --git-dir=$git diff --diff-filter=A --name-only \ + $GIT diff --diff-filter=A --name-only \ ${commit}~..$commit | while read -r newfile do if [ -f "$newfile" ] @@ -158,10 +158,10 @@ do continue fi - git --git-dir=$git show $commit | patch -p 1 -s || \ + $GIT show $commit | patch -p 1 -s || \ error "Failed to apply patch" - git --git-dir=$git diff --diff-filter=A --name-only \ + $GIT diff --diff-filter=A --name-only \ ${commit}~..$commit | while read -r newfile do svn add --parents --depth=infinity $newfile || \ @@ -176,7 +176,7 @@ do exit $ret fi - git --git-dir=$git show -s --format='%B' $commit | svn commit -F - || \ + $GIT show -s --format='%B' $commit | svn commit -F - || \ error "Failed to commit" done