public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* [patch] CT_ExtractGit
@ 2011-10-07 13:15 Esben Haabendal
  2011-10-07 13:24 ` Esben Haabendal
  2011-10-16 15:08 ` Yann E. MORIN
  0 siblings, 2 replies; 3+ messages in thread
From: Esben Haabendal @ 2011-10-07 13:15 UTC (permalink / raw)
  To: crossgcc

# HG changeset patch
# User Esben Haabendal <esben.haabendal@prevas.dk>
# Date 1317992804 -7200
# Node ID 34d13602e8cc46247f19a2c498df0cf060064d3d
# Parent  7501f41e3bbfa01aea66d5a2ce2343f69306009f
Fix CT_ExtractGit function.

Change CT_ExtractGit so that it clones the repository, instead of just
symlinking it.  After cloning, any given ref is checked out, or if no
ref is given, the HEAD of the repository is checked out.

This makes CT_Extract behave similar for git repositories as it does
for tarballs, so that it fx. can be used for passing glibc-ports as a
git repository.

diff -r 7501f41e3bbf -r 34d13602e8cc scripts/functions
--- a/scripts/functions	Thu Oct 06 00:09:00 2011 +0200
+++ b/scripts/functions	Fri Oct 07 15:06:44 2011 +0200
@@ -787,12 +787,13 @@
     CT_Popd
 }
 
-# Create a working git clone
+# Create a working git clone of a local git repository
 # Usage: CT_ExtractGit <basename> [ref]
 # where 'ref' is the reference to use:
 #   the full name of a branch, like "remotes/origin/branch_name"
 #   a date as understandable by git, like "YYYY-MM-DD[ hh[:mm[:ss]]]"
 #   a tag name
+# If 'ref' is not given, the current repository HEAD will be used
 CT_ExtractGit() {
     local basename="${1}"
     local ref="${2}"
@@ -800,13 +801,13 @@
     local ref_type
 
     # pushd now to be able to get git revlist in case ref is a date
-    clone_dir="${CT_TARBALLS_DIR}/${basename}"
-    CT_Pushd "${clone_dir}"
+    repo="${CT_TARBALLS_DIR}/${basename}"
+    CT_Pushd "${repo}"
 
     # What kind of reference is ${ref} ?
     if [ -z "${ref}" ]; then
-        # Don't update the clone, keep as-is
-        ref_type=none
+        ref_type=head
+        ref=$(git rev-list -n1 HEAD)
     elif git tag |grep -E "^${ref}$" >/dev/null 2>&1; then
         ref_type=tag
     elif git branch -a --no-color |grep -E "^. ${ref}$" >/dev/null
2>&1; then
@@ -818,15 +819,17 @@
         CT_Abort "Reference '${ref}' is an incorrect git reference:
neither tag, branch nor date"
     fi
 
-    CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/${basename}"
-    CT_DoExecLog ALL ln -sf "${clone_dir}" "${CT_SRC_DIR}/${basename}"
+    CT_Popd
 
+    CT_DoExecLog FILE rmdir "${basename}"
     case "${ref_type}" in
-        none)   ;;
-        *)      CT_DoExecLog FILE git checkout "${ref}";;
+        branch) CT_DoExecLog FILE git clone -b "${ref}" "${repo}"
"${basename}" ;;
+        *)      CT_DoExecLog FILE git clone "${repo}" "${basename}"
+                CT_Pushd "${basename}"
+                CT_DoExecLog FILE git checkout "${ref}"
+                CT_Popd
+                ;;
     esac
-
-    CT_Popd
 }
 
 # Patches the specified component



-- 
ESBEN HAABENDAL, Senior Software Designer
Prevas A/S, Hedeager 1, DK-8200 Aarhus N, www.prevas.dk
Central: +45 87 43 80 70  Direct: +45 51 92 53 93
E-mail: esben.haabendal@prevas.dk

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: [patch] CT_ExtractGit
  2011-10-07 13:15 [patch] CT_ExtractGit Esben Haabendal
@ 2011-10-07 13:24 ` Esben Haabendal
  2011-10-16 15:08 ` Yann E. MORIN
  1 sibling, 0 replies; 3+ messages in thread
From: Esben Haabendal @ 2011-10-07 13:24 UTC (permalink / raw)
  To: crossgcc

Signed-off-by: "Esben Haabendal" <esben.haabendal@prevas.dk>

On Fri, 2011-10-07 at 15:15 +0200, Esben Haabendal wrote:
> # HG changeset patch
> # User Esben Haabendal <esben.haabendal@prevas.dk>
> # Date 1317992804 -7200
> # Node ID 34d13602e8cc46247f19a2c498df0cf060064d3d
> # Parent  7501f41e3bbfa01aea66d5a2ce2343f69306009f
> Fix CT_ExtractGit function.
> 
> Change CT_ExtractGit so that it clones the repository, instead of just
> symlinking it.  After cloning, any given ref is checked out, or if no
> ref is given, the HEAD of the repository is checked out.
> 
> This makes CT_Extract behave similar for git repositories as it does
> for tarballs, so that it fx. can be used for passing glibc-ports as a
> git repository.
> 
> diff -r 7501f41e3bbf -r 34d13602e8cc scripts/functions
> --- a/scripts/functions	Thu Oct 06 00:09:00 2011 +0200
> +++ b/scripts/functions	Fri Oct 07 15:06:44 2011 +0200
> @@ -787,12 +787,13 @@
>      CT_Popd
>  }
>  
> -# Create a working git clone
> +# Create a working git clone of a local git repository
>  # Usage: CT_ExtractGit <basename> [ref]
>  # where 'ref' is the reference to use:
>  #   the full name of a branch, like "remotes/origin/branch_name"
>  #   a date as understandable by git, like "YYYY-MM-DD[ hh[:mm[:ss]]]"
>  #   a tag name
> +# If 'ref' is not given, the current repository HEAD will be used
>  CT_ExtractGit() {
>      local basename="${1}"
>      local ref="${2}"
> @@ -800,13 +801,13 @@
>      local ref_type
>  
>      # pushd now to be able to get git revlist in case ref is a date
> -    clone_dir="${CT_TARBALLS_DIR}/${basename}"
> -    CT_Pushd "${clone_dir}"
> +    repo="${CT_TARBALLS_DIR}/${basename}"
> +    CT_Pushd "${repo}"
>  
>      # What kind of reference is ${ref} ?
>      if [ -z "${ref}" ]; then
> -        # Don't update the clone, keep as-is
> -        ref_type=none
> +        ref_type=head
> +        ref=$(git rev-list -n1 HEAD)
>      elif git tag |grep -E "^${ref}$" >/dev/null 2>&1; then
>          ref_type=tag
>      elif git branch -a --no-color |grep -E "^. ${ref}$" >/dev/null
> 2>&1; then
> @@ -818,15 +819,17 @@
>          CT_Abort "Reference '${ref}' is an incorrect git reference:
> neither tag, branch nor date"
>      fi
>  
> -    CT_DoExecLog DEBUG rm -f "${CT_SRC_DIR}/${basename}"
> -    CT_DoExecLog ALL ln -sf "${clone_dir}" "${CT_SRC_DIR}/${basename}"
> +    CT_Popd
>  
> +    CT_DoExecLog FILE rmdir "${basename}"
>      case "${ref_type}" in
> -        none)   ;;
> -        *)      CT_DoExecLog FILE git checkout "${ref}";;
> +        branch) CT_DoExecLog FILE git clone -b "${ref}" "${repo}"
> "${basename}" ;;
> +        *)      CT_DoExecLog FILE git clone "${repo}" "${basename}"
> +                CT_Pushd "${basename}"
> +                CT_DoExecLog FILE git checkout "${ref}"
> +                CT_Popd
> +                ;;
>      esac
> -
> -    CT_Popd
>  }
>  
>  # Patches the specified component
> 
> 
> 


-- 
ESBEN HAABENDAL, Senior Software Designer
Prevas A/S, Hedeager 1, DK-8200 Aarhus N, www.prevas.dk
Central: +45 87 43 80 70  Direct: +45 51 92 53 93
E-mail: esben.haabendal@prevas.dk

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

* Re: [patch] CT_ExtractGit
  2011-10-07 13:15 [patch] CT_ExtractGit Esben Haabendal
  2011-10-07 13:24 ` Esben Haabendal
@ 2011-10-16 15:08 ` Yann E. MORIN
  1 sibling, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2011-10-16 15:08 UTC (permalink / raw)
  To: crossgcc; +Cc: Esben Haabendal

Esben, All,

On Friday 07 October 2011 15:15:24 Esben Haabendal wrote:
> # HG changeset patch
> # User Esben Haabendal <esben.haabendal@prevas.dk>
> # Date 1317992804 -7200
> # Node ID 34d13602e8cc46247f19a2c498df0cf060064d3d
> # Parent  7501f41e3bbfa01aea66d5a2ce2343f69306009f
> Fix CT_ExtractGit function.

Applied with minor tweaks as #7b64746b0ab3. Thank you!

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

--
For unsubscribe information see http://sourceware.org/lists.html#faq

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

end of thread, other threads:[~2011-10-16 15:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-07 13:15 [patch] CT_ExtractGit Esben Haabendal
2011-10-07 13:24 ` Esben Haabendal
2011-10-16 15:08 ` Yann E. MORIN

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