emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [patch] to allow org-attach-git to handle individual repositories
@ 2021-01-31 19:37 Juan Manuel Macías
  2021-04-28  3:57 ` Bastien
  2021-05-15 14:08 ` Bastien
  0 siblings, 2 replies; 4+ messages in thread
From: Juan Manuel Macías @ 2021-01-31 19:37 UTC (permalink / raw)
  To: orgmode; +Cc: Ihor Radchenko

[-- Attachment #1: Type: text/plain, Size: 589 bytes --]

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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-attach-git-individual-repositories.patch --]
[-- Type: text/x-patch, Size: 2664 bytes --]

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))

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] to allow org-attach-git to handle individual repositories
  2021-01-31 19:37 [patch] to allow org-attach-git to handle individual repositories Juan Manuel Macías
@ 2021-04-28  3:57 ` Bastien
  2021-04-28 13:42   ` Juan Manuel Macías
  2021-05-15 14:08 ` Bastien
  1 sibling, 1 reply; 4+ messages in thread
From: Bastien @ 2021-04-28  3:57 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode, Ihor Radchenko

Hi Juan,

Juan Manuel Macías <maciaschain@posteo.net> writes:

> 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

thanks for the patch and sorry for the slow reply.

It looks good but it is significative enough to require you to sign
the FSF copyright assignment.  If you're willing to go through this
(which will secure future contributions too), please see:

https://orgmode.org/request-assign-future.txt

Thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] to allow org-attach-git to handle individual repositories
  2021-04-28  3:57 ` Bastien
@ 2021-04-28 13:42   ` Juan Manuel Macías
  0 siblings, 0 replies; 4+ messages in thread
From: Juan Manuel Macías @ 2021-04-28 13:42 UTC (permalink / raw)
  To: Bastien; +Cc: orgmode

Hi Bastien,

Bastien writes:

> It looks good but it is significative enough to require you to sign
> the FSF copyright assignment.  If you're willing to go through this
> (which will secure future contributions too), please see:

Thanks for the advice. I just signed and sent the FSF copyright
assignment.

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] to allow org-attach-git to handle individual repositories
  2021-01-31 19:37 [patch] to allow org-attach-git to handle individual repositories Juan Manuel Macías
  2021-04-28  3:57 ` Bastien
@ 2021-05-15 14:08 ` Bastien
  1 sibling, 0 replies; 4+ messages in thread
From: Bastien @ 2021-05-15 14:08 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode, Ihor Radchenko

Hi Juan,

Juan Manuel Macías <maciaschain@posteo.net> writes:

> 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

Applied in master with a commit message, thanks.

-- 
 Bastien


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-15 14:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-31 19:37 [patch] to allow org-attach-git to handle individual repositories Juan Manuel Macías
2021-04-28  3:57 ` Bastien
2021-04-28 13:42   ` Juan Manuel Macías
2021-05-15 14:08 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).