From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id mERJOT0HF2CNGAAA0tVLHw (envelope-from ) for ; Sun, 31 Jan 2021 19:38:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id mJz/ND0HF2AoXQAAbx9fmQ (envelope-from ) for ; Sun, 31 Jan 2021 19:38:37 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 233FF940309 for ; Sun, 31 Jan 2021 19:38:37 +0000 (UTC) Received: from localhost ([::1]:51886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l6IYO-0004Wa-3w for larch@yhetil.org; Sun, 31 Jan 2021 14:38:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6IXP-0004WP-4g for emacs-orgmode@gnu.org; Sun, 31 Jan 2021 14:37:35 -0500 Received: from mout01.posteo.de ([185.67.36.65]:36365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l6IXL-00035G-U5 for emacs-orgmode@gnu.org; Sun, 31 Jan 2021 14:37:34 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id BACB1160060 for ; Sun, 31 Jan 2021 20:37:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1612121849; bh=M9kIqy4UIB0yhIlgKkC9lVm3tcB0IFMFHSwrZTbaEOs=; h=From:To:Cc:Subject:Date:From; b=QQfFlIT1/xtnv5ONJaqQQRGOQ8YaMpKR49SetOadkegzpyw5Bp6Xczqv8sU24lqxo gPEDIfkvcMVxpcVLiyUz8tnvxK5QoExxsdzjNB8X2HSYQK2Ayd+pWS2YV2b9Spdo1m FvI7WJwkC0PjiKjEw/H0lwH2iOe/tP2XF4lwB49Kxq/Yk0y+WcslrOmbLy1s7dS3Td tVU4SMRJ18CoY3g0NZoQbJyEV/DV1gaRSXnbOj5n2YLSQv7NAofN4miYEgSmZyr+b+ H2Hw4+lbHwrPHqmDsgmMwXh8/p15rJmMal8dFuHj4mnIwkLfCwPrJ98F99nEMlIVla pQQOJjK19yqFg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4DTLvD3GqRz9rxX; Sun, 31 Jan 2021 20:37:28 +0100 (CET) From: =?utf-8?Q?Juan_Manuel_Mac=C3=ADas?= To: orgmode Subject: [patch] to allow org-attach-git to handle individual repositories Date: Sun, 31 Jan 2021 20:37:27 +0100 Message-ID: <87y2g8rj7s.fsf@posteo.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=maciaschain@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ihor Radchenko Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.06 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=QQfFlIT1; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 233FF940309 X-Spam-Score: -3.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3OM3TBhvtb7M --=-=-= Content-Type: text/plain Hi, I would like to propose and discuss this patch for org-attach-git, following a series of comments and suggestions from Ihor Radchenko in this thread: https://lists.gnu.org/archive/html/emacs-orgmode/2021-01/msg00483.html This patch would allow org-attach-git to handle individual repositories, that is, any repository initialized in a directory attached to a node. A custom variable is provided, that admits two values: 1. default: the default value, which is equivalent to the old behavior 2. individual-repository: which activates the 'new' feature. Best regards, Juan Manuel --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=org-attach-git-individual-repositories.patch diff --git a/lisp/org-attach-git.el b/lisp/org-attach-git.el index 2091cbc61..54df5b9ba 100644 --- a/lisp/org-attach-git.el +++ b/lisp/org-attach-git.el @@ -52,9 +52,26 @@ If \\='ask, prompt using `y-or-n-p'. If t, always get. If nil, never get." (const :tag "always get from annex if necessary" t) (const :tag "never get from annex" nil))) +(defcustom org-attach-git-dir 'default + "The attachment directory where a Git repository must be +handled. The default value is `default', which is equivalent to +`org-attach-id-dir'. If the value is `individual-repository', it +means that the directory attached to the current node should be +handled as a individual repository, as long as it has been +conveniently initialized." + :group 'org-attach + :package-version '(Org . "9.0") + :version "26.1" + :type '(choice + (const :tag "Default" default) + (const :tag "Individual repository" individual-repository))) + (defun org-attach-git-use-annex () "Return non-nil if git annex can be used." - (let ((git-dir (vc-git-root (expand-file-name org-attach-id-dir)))) + (let ((git-dir (vc-git-root (cond ((eq org-attach-git-dir 'default) + (expand-file-name org-attach-id-dir)) + ((eq org-attach-git-dir 'individual-repository) + (org-attach-dir)))))) (and org-attach-git-annex-cutoff (or (file-exists-p (expand-file-name "annex" git-dir)) (file-exists-p (expand-file-name ".git/annex" git-dir)))))) @@ -62,7 +79,10 @@ If \\='ask, prompt using `y-or-n-p'. If t, always get. If nil, never get." (defun org-attach-git-annex-get-maybe (path) "Call git annex get PATH (via shell) if using git annex. Signals an error if the file content is not available and it was not retrieved." - (let* ((default-directory (expand-file-name org-attach-id-dir)) + (let* ((default-directory (cond ((eq org-attach-git-dir 'default) + (expand-file-name org-attach-id-dir)) + ((eq org-attach-git-dir 'individual-repository) + (org-attach-dir)))) (path-relative (file-relative-name path))) (when (and (org-attach-git-use-annex) (not @@ -86,7 +106,10 @@ This checks for the existence of a \".git\" directory in that directory. Takes an unused optional argument for the sake of being compatible with hook `org-attach-after-change-hook'." - (let* ((dir (expand-file-name org-attach-id-dir)) + (let* ((dir (cond ((eq org-attach-git-dir 'default) + (expand-file-name org-attach-id-dir)) + ((eq org-attach-git-dir 'individual-repository) + (org-attach-dir)))) (git-dir (vc-git-root dir)) (use-annex (org-attach-git-use-annex)) (changes 0)) --=-=-=--